When degugging an Errai application in Eclipse, I get the following error.
[WARN] failed com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload#1575d48{/,/home/matthew/git/PressGangCCMSUI/src/main/webapp}: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] failed RequestLogHandler#ad4bb0: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
[WARN] Error starting handlers
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/context/FacesContext
Does anyone know how to fix this up?
It turns out the issue was because Eclipse was using a local Maven project as a dependency instead of the JAR file in the local repo cache. Once I close the project that my Errai app was dependant on, Eclipse reverted back to using the JAR in the local repo cache, and I could launch the debugger again.
Related
Error when building a Maven project using maven-scala-plugin:
[ERROR] Error: Could not find or load main class scala_maven_executions.MainWithArgsInFile
Then reason is that settings.xml file was copied from Windows to OS X without modification, however it contained Windows-specific local repository path:
<localRepository>C:\Users\<username>\.m2\repository</localRepository>
Should be changed to:
<localRepository>/Users/<username>/.m2/repository</localRepository>
I´ve been having trouble getting the Super-Dev-Mode to work with GWT 2.7. and GXT 3.1.x The classical Dev-Mode starts without trouble, but the Super-Dev-Mode and GWT-compile the project won`t work.
I am currently working with Eclipse 4.4.2 with Java 1.7_2 on Windows.
So let´s pretend we have 2 GWT/GXT projects (no Maven) with GWT 2.6 and GXT 3.1.x (Projects are backuped on a repository).
One is called A and the other project is called B. Project A has many packages and no entrypoint (to just work as a library/framework), just an abstract entrypoint every other project has to extend. The other one is called B and inherits from A, the entrypoint extends the entrypoint of A.
When starting the project under GWT 2.6 in classical Dev-Mode the project works fine. When upgrading to GWT 2.7. it will work fine with the classical Dev-Mode, an even in Super-Dev-Mode the Codeserver starts to run, but when compiling the module i get an error that some code seems not to live under a package 'client' so i migrated it into a own package and added the sourcepath to the A.gwt.xml.
After fixing this error and starting the Super-Dev-Mode again (and when trying to GWT-compile) I get errors like this:
Ignored 15 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Finding entry point classes
Tracing compile failure path for type 'com.example.b.client.B'
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/B.java'
[ERROR] com.example.a.client.A cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/view/ExampleLayout.java'
[ERROR] com.example.a.view.ILayout cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/client/service/ExampleServiceAsync.java'
[ERROR] com.example.a.model.Examplemodel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/model/OtherExampleModel.java'
[ERROR] com.example.a.hibernate.model.ComOtherExampleModel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/service/OtherExampleServiceAsync.java'
[ERROR] com.example.a.model.NewExampleModel cannot be resolved to a type
...
(and many more)
Project A is included in the buildpath of the project B, when creating a custom run configuration where the project is added to "user entries" and adding source folders to "user" entries wont work. For the custom run configuration i used something like the following arguments:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B"
And even:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B com.example.a.A"
I widely searched for solutions and even tried to set up the workspace again, checkout the projects from the repository again, organize imports and even adding every package to the buildpath of A.
I also tried to add this to the .gwt.xml files didn´t work:
<add-linker name="xsiframe"/>
How can I solve the "cannot be resolved to a type" error?
I would really appreciate every form of help to get this problem done! Thanks!
One possible problem could be your version of GXT. If you are using GXT 3.1.1 (which was the latest GPL-release), then you can not use GWT 2.7.0.
Take a look at the version table:
GXT versions
As you can see, Sencha GXT 3.1.1 does not support GWT 2.7.0. The first GXT release which will support GWT 2.7.0 is GXT 3.1.2.
I am trying to write a Play 2.3.8 application in Scala, managing it via sbt but editing it in Eclipse. I worked round one problem, but this seems to introduce another, and cannot work out how to solve it.
I set up the project using the exact instructions to Create a new application without Activator (except I also add
scalaVersion := "2.11.6"
to build.sbt), then I cd to my project directory, type sbt and once in sbt I type eclipse. Then I open Eclipse and happily import the project.
Now I create a simple template (app/views/Application/index.scala.html) and a controller which calls it (app/controllers/Application.scala). When I go into sbt and type run I can happily open my web browser at localhost:9000 and my populated template appears.
All is good apart from one problem (the first one). When I open up Application.scala in Eclipse I get a wiggly red error line saying "object Application is not a member of package views.html". I solved that using Nick Cooper's answer elsewhere on Stack Overflow. He said to go to Project > Properties > Java Build Path > Libraries > Add Class Folder... and then add target/scala-2.11/classes_managed. That makes the error go away. But I don't want to manage Eclipse's settings directly; I want to manage everything via sbt. So by trial and error I found that I can add this line to my build.sbt file...
unmanagedJars in Compile += ( baseDirectory.value / "target/scala-2.11/classes_managed" )
...and now I can type sbt followed by eclipse and Eclipse's config is generated correctly, with no wiggly red line errors.
But this creates a second problem. It turns out that by introducing that line into build.sbt the application no longer runs. Specifically when I go into sbt, type run and open localhost:9000 I get a NoClassDefFoundError exception in my sbt console:
java.lang.NoClassDefFoundError: controllers/Application$
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(routes_routing.scala:51) ~[classes_managed/:na]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(routes_routing.scala:51) ~[classes_managed/:na]
at play.core.Router$HandlerInvokerFactory$$anon$13$$anon$14.call(Router.scala:217) ~[play_2.11-2.3.8.jar:2.3.8]
at play.core.Router$Routes$TaggingInvoker.call(Router.scala:464) ~[play_2.11-2.3.8.jar:2.3.8]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1.apply(routes_routing.scala:51) ~[classes_managed/:na]
Caused by: java.lang.ClassNotFoundException: controllers.Application$
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_40]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_40]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(routes_routing.scala:51) ~[classes_managed/:na]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(routes_routing.scala:51) ~[classes_managed/:na]
[error] application - Error while rendering default error page
scala.MatchError: java.lang.NoClassDefFoundError: controllers/Application$ (of class java.lang.NoClassDefFoundError)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:148) ~[play_2.11-2.3.8.jar:2.3.8]
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:206) [play_2.11-2.3.8.jar:2.3.8]
at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:63) [play_2.11-2.3.8.jar:2.3.8]
at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:73) [play_2.11-2.3.8.jar:2.3.8]
at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:71) [play_2.11-2.3.8.jar:2.3.8]
You can see the entire (tiny) codebase on Github.
All the class files seem to be all there, and in exactly the same locations, regardless of whether or not I include the "unmanagedJars" line. It's not an Eclipse problem because it happens even when Eclipse is closed. It seems to be a classpath issue (but I can't understand why adding to a classpath should hide some classes). Regardless of that, I'd like to manage my project with sbt and use Eclipse just as the editor. What am I getting wrong?
I have found a solution through further trial and error. Instead of extending the classpath to "target/scala-2.11/classes_managed" it should be extended to "target/scala-2.11/classes". In other words the line in build.sbt should be
unmanagedJars in Compile += ( baseDirectory.value / "target/scala-2.11/classes" )
Now from sbt I can compile, test and run the application, and connect successfully to localhost:9000, and I can also open the files in Eclipse without seeing error lines.
I still don't know why the NoClassDefFoundError really occurred in the previous setup, but that's a problem for another day.
I am using activator but I guess it might be the same.
So, Eclipse does not really like structural changes in a Play project or adding/removing libraries (via libraryDependencies, etc) and displays red squiggly things everywhere. This is how I solve them:
activator clean compile
If I have added/removed libraries, I run
activator eclipse
so that Eclipse gets the changes.
It works everytime. Clean, clean, clean. I actually found this solution somewhere on the Net a while a go but cannot remember where, sorry.
EDIT
And refresh the project in Eclipse!
Ok, I want to manage Constants at Server level, so com.mattbertolini.hermes.Hermes is a solution.
Please see all my steps:
1- I downloaded hermes-1.2.0.jar & import into correct Library of eclipse (no problem)
2- Create MyConstantsWithLookup.java at client package
import com.google.gwt.i18n.client.ConstantsWithLookup;
public interface MyConstantsWithLookup extends ConstantsWithLookup {
String myMsg();
}
3- create MyConstantsWithLookup.properties file in the same client package. The file has this line:
myMsg=Deleted
4- In ServerData.java in Server package
MyConstantsWithLookup my = Hermes.get(MyConstantsWithLookup.class, "");
String extra=my.myMsg();
When tested in eclipse it works fine but I got Warnign message in eclipse:
[WARN] Server class 'com.ibm.icu.util.ULocale' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/eclipse-jee-juno-SR1-win32-x86_64/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201212122042-rel-r42/gwt-2.5.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/C:/Users/eclipse-jee-juno-SR1-win32-x86_64/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.5.0.v201212122042-rel-r42/gwt-2.5.0/doc/helpInfo/webAppClassPath.html
I am not sure what this warning's about? is it serious?
The code was running ok but why eclipse generated this warning?
This class (com.ibm.icu.util.ULocale) is a replacement for java.util.Locale, so it seems Hermes has a dependency on it.
Download the ICU4J jar from http://site.icu-project.org/download and add it to your project's build path.
Source: Matt Bertolini at https://github.com/mattbertolini/Hermes/issues/3
You need to add the ICU4j jar located at http://site.icu-project.org/
to your classpath. The reason you have the ICU classes inside the
gwt-dev.jar is because GWT includes them for its Java to JavaScript
compiler. This is regrettable since it often times falsely reports the
files on your classpath.
I am just starting with GWT. I use Eclipse and have installed the GWT plugin.
I have followed the directions here Maven GWT 2.0 and Eclipse to set up a GWT project using the gwt-maven-plugin. When I run the Maven goals gwt:compile gwt:run, GWT Development Mode is launched and I can copy the url from it to my browser and view the label.
However, the project has this problem:
Description: The web.xml file does not exist
Resource: WEB-INF
Path: /GWTExample/war
Location: Unknown
Type: Google Web App Problem
If I try to run the project as a Google Web Application, I get this warning:
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
I can get rid of the problem by copying the web.xml to the war directory, but I still get the URL issue when running as a Google Web App.
If I'm using Maven and GWT in Eclipse, should I just ignore the web.xml problem and always run applications in development mode via the Maven goals? Or is there a way to set things so I can run as a Google Web App?
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run? I have added breakpoints to my application but it doesn't stop on them. I'm not sure if it is something I've configured wrong or if it's just not possible.
Update:
In response to Prem's answer...
When I run a compile gwt:run, the web.xml file isn't copied. When I run the install gwt:run, I get this error:
[INFO] --- gwt-maven-plugin:1.2:test (default) # SampleGWT ---
[INFO] using GWT jars from project dependencies : 2.0.4
[INFO] establishing classpath list (scope = test)
[ERROR] java.lang.NoClassDefFoundError: org/codehaus/mojo/gwt/test/MavenTestRunner
[ERROR] Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.gwt.test.MavenTestRunner
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[ERROR] Could not find the main class: org.codehaus.mojo.gwt.test.MavenTestRunner. Program will exit.
[ERROR] Exception in thread "main"
I’m guessing that bug http://jira.codehaus.org/browse/MGWT-24 is included in version 1.2 of the gwt-maven-plugin. Normally I wouldn’t run install on a project that builds a war file, but I would expect to at least get past the test phase of the build cycle.
Does anybody have any idea why I would get this error on the install but not the compile goals? Also, should I be expecting either goal to copy the web.xml file from src/main/webapp/WEB-INF/web.xml to the /war directory?
Description: The web.xml file does not exist
gwt-maven-plugin creates a project with 'war' packaging format (it's a web app so no surpirse here). Web.xml for this project will be under 'src/main/webapp' folder which will be copied to the 'war' directory (which is set as the output directory) as part of the 'resources' phase in the maven build life-cycle. You should always use
mvn compile gwt:run
or
mvn install gwt:run
so that resources are copied, all java files are compiled and gwt:compile is also invoked (since it is bound to the 'compile' phase automatically)
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
As per the stackoverflow link you used as reference, only your maven build file is setup with startupUrl. In order for it to work in Eclipse, you must edit the Run Configuration of your project and add the '-statupUrl' command line arguments to the existing arguments in the "Arguments" panel.
However, this is just a warning and it should not stop you from running your GWT application from eclipse. If you are facing the same "web.xml" problem here as well, it could be because you did not compile your project in your IDE before invoking "Run as Web Application". I suggest you to disable "Build Automatically" option for this project and always build it manually and invoke "GWT Compile" and then try "Run as web application"
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run?
In general you must use "Remote Application" debug configuration for remote debugging a process. However I am not sure if it will work for GWT projects.
I got me too this warning:
No startup URLs supplied and no plausible ones found
when I have followed this gwt tutorial
In that screenshot there is no checkbox with "Generate sample code" . In my IDE ( sdk 2.5) it is, so I have unchecked...
It wasn't created any of the server and client packages, I have created the client manually, as the tutorial required. The tutorial until that step doesn't say I must have a server package too. That and his configuration is missing from project.
If you right-click on your project and go to Properties -> Google -> Web Application, your WAR directory might be something like either war or src/main/webapp/WEB-INF/classes.
Change that to src/main/webapp.
Also un-check the box next to "Launch and delploy from this directory..."
That's what fixed this problem for me. It also fixed the "can't find gwt-servlet.jar" problem at the same time.