"Unable to find XXX.gwt.xml on your classpath" error in GWT - eclipse

After importing a Maven GWT project into Eclipse the debugger doesn't work, complaining that it's
Unable to find ProjectName.gwt.xml on your classpath
How do you fix this error?

It turns out that when you debug some GWT project as Web Applications, Eclipse does not append the module name (i.e. the gwt.xml file) to the list of arguments. I tried adding it manually, but forgot to add the complete package name that houses the gwt.xml file. The module should have been referred to as com.company.project.Project.gwt.xml, not just Project.gwt.xml.

I found that Davek804's comment helped me: I simply deleted the debug configuration (Run=>Debug Configuration=>right click and deleted project will run

Try going to Run -> Run Configurations in the menu and then select the Classpath tab and add the missing project.

Related

Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program

I've created a Play Framework program via Typesafe Activator (so it follows the template exactly).
I used sbteclipse-plugin version 3.0.0 to create an Eclipse project and imported that into Scala IDE 4.0.0. These are all the latest versions at the time of writing.
The Scala IDE definitely seems to support the Play Framework. It has syntax highlighting for the custom formats, including the routing file and templates. Yet, it doesn't seem to be able to find the views from the controllers. In particular, the call to views.html.index triggers an error: "object index is not a member of package views.html".
I tried enabling refreshing using native hooks or pooling as detailed here, but it had no affect.
I should note that while the code has been compiled in the command line (with activator ~run), it hasn't been compiled in Scala IDE, since I don't know how to (it doesn't seem to be documented anywhere).
What can I do to get rid of these false errors?
EDIT: After running activator clean ~run, I have another error: The project cannot be built until build path errors are resolved. There's no further details on what these build path errors are.
Update: Just upgrade to sbteclipse version 5.1.0 and everything should work out of the box. Also make sure you follow the Play documentation on how to set up Eclipse/ScalaIDE.
This is a known bug in sbteclipse, which probably will be fixed soon.
For now, you can add the following line to your build.sbt:
EclipseKeys.createSrc := EclipseCreateSrc.All
Kill the SBT console and run sbt eclipse again. That should add the following line to the .classpath file within your project folder as a workaround:
<classpathentry kind="src" path="target/scala-2.11/twirl/main"/>
Refresh your Eclipse project to pick up the change.
I had the same issue, also with Scala IDE 4.0.0 . I followed mkurz instuctions and they worked like a charm. But instead of changing the .classpath file in the project folder manually I used Eclipse interface:
In the top menu of the main window, click on Project and then on Properties.
In the Properties window, click on Java Build Path option (options list is on the left)
In the Source tab, click on Add Folder... button.
In the Source Folder Selection window, choose the target/scala-2.11/twirl/main folder, so it is included in the compilation path. Click Ok button.
Click Ok in the Properties window.
Now the project should compile just fine :) . With that I was able to finish the play setup example in Scala IDE website
I tried #mkurz solution first, but also ran into the same error as #matt. I became frustrated that I could not generate the eclipse project without having to go to the Eclipse project properties to manually fix the build errors. After some investigation, I discovered the solution that removed all errors entirely. Add this your build.sbt:
unmanagedSourceDirectories in Compile <+= twirlCompileTemplates.target
Or if that does not work for you, you could also use:
unmanagedSourceDirectories in Compile <+= target.zipWith(scalaBinaryVersion) { (b,v) => b / s"scala-$v/twirl/main" }
Good bye, build errors!
I got the same error message.
Are you using java8 as jre in eclipse?
After switching back from java8 to java7, everything worked fine again.
If, after following Mkurz' instructions (adding EclipseKeys.CreateSrc... ), your problems are not solved, click on Project -> Properties -> Java Build Path. Look at the source folders tab.
You may find a duplicate file folder named .../src_managed/main (Thanks Matt). If so, close the project. Remove ONE of the two ../src_managed/main entries from the .classpath file (located in the base of the activator/SBT project directory). Reopen and clean the project and you should be good to go.
For me, it turned out that installed JRE in the Scala IDE was openjdk, changed it to Oracle Java 8 and it worked.

Groovy Eclipse can't launch junit tests

In Eclipse with groovy plugin, I try to launch a test #Test public void testToLaunch() {...} but I have the error:
The input type of the launch configuration does not exist
What input type is in the context of launch configuration? (can't find such an entry in launch configuration window)
Note: I try sts 2.8.1 and e3.7
This happens normally when the folder in which test case is present is not a source folder, please check this post as well.
Hope that helps!
This can also happen if there is a problem with the groovy class. A few things to check:
1) Ensure that the class name exactly matches the filename (filename = MyTest.groovy)
package com.mypackage;
import groovy.util.GroovyTestCase;
class MyTest extends GroovyTestCase {}
2) Ensure that the package defined in the file matches the package the file is actually in.
In Eclipse you can do
Right click -> properties -> Java build path
Notice test folder is not available in sources. Add it.
Add folder -> Select test -> OK
Now rerun you unit test cases.
This happened to me, and I just restarted Eclipse (GGTS) and everything was fine again.
I had a spelling mistake which lead to that error message. My test class file name was named JUnit5Test.java (with upper U) and the class itself was named Junit5Test (with lower u).
I was using Spring Tool Suite 4 (4.8.0.RELEASE).
This also happened to me. But these tests are written in Groovy. The problem I encountered has to do with how the IDE (Eclipse Kepler, Java EE) first opens a Groovy project after executing "mvn eclipse:eclipse".
The Build Paths do not reference the Groovy source files correctly.
To resolve, I:
Right-click on the project, select "Build Path" > "Configure Build Path..."
Select "Source" tab
For test and src folders (.../src/main/groovy, and .../src/test/groovy)
make sure "**/*.groovy" is set as "Inclusion patterns", not "**/*.java"
Hope this saves time for someone.
Cheers!
I had the same error message when I head the test-class duplicated both in the main Java source folder and the testsrc folder. Removing the incorrectly placed one in the main Java source folder solved the problem for me.
2019 Update: This drove me crazy for days even with latest Eclipse and fresh installs (Mac, Grails 4, Gradle 5.1.1, Java 8). Some above examples led me to the solution.
My problem was more that the code I was testing included a mix of groovy and java src/main code. It gave me NoClassDefFound on the .groovy classes when I ran my Spec as JUnit.
Solution: I had to modify my Run/Debug Configuration to include build/classes/groovy/main. Then it worked. It's a little bit of a pain to remember to that for every new Configuration, but, it keeps me going. I hope it helps you.
Whenever you create a Junit test in eclipse, make sure your Junit test file is inside src/test/java folder.
I had a similar problem. Like others have already pointed out, it was about source folders. I had to change my source folder setup. There was an empty src-folder that disappeared after I right-clicked on it and selected 'remove from build path' from Build path menu. After that I right-clicked both java/src and java/test folders and chose Build path > Use as a source folder. And suddenly my tests were JUnited!
In similar situations I'd advice to remove all source folders from build path and add them again when you're sure you've got the right ones. Your source folders should be those with Java package structure under them. In case of proj/java/test/com/stackoverflow/main it's the 'test' folder.
This is what resolved for me (Eclipse Oxygen). I had already done what Robert suggested in the earlier post. I was still getting the error. When I went to edit the configuration for junit launch, I saw that the Test Class field just had the class name. I had to hit the Search button to the right. The Test Class field now had the complete name for the class
com.mycompany.mypackage.MyClass
With this I am able to run the JUnit. But I have to keep fixing this for every run.
Found another way to cause this message. The cause turned out to be an empty copy of MyTest.java under src/main/java, as well as the real one under src/test/java.
Think the empty file was a hangover from some refactoring and was oddly causing no compile errors either. Deleting it enabled the test to run again.

No Class Def Found Error in my JSP file

I have a jsp file called AddBidding.jsp which adds bids for a facility. I am using the Google App Engine's datastore (objectify). When I try to run the file using localhost:8888/AddBidding.jsp. However, it keeps giving me NoClassDefinitionFound Error. Can I know what causes this error? I know it's due to the classpath but how do I fix it in Eclipse GAE?
I am making some assumptions over here since there are not too many details about which class is giving you the NoClassDefFound Error. Just ensure that all the external(additional) JARs that you use are present in the WEB-INF\lib folder also. For e.g. put all the Objectify and dependent JARs in the WEB-INF\lib folder and then try.
Right Click the Project on Project Explorer View > "Configure Build Path"
In Source [tab] Make sure your Default output folder is right
In Libraries [tab] you have Web App Libraries
If not Add Library...
That should get you working.

Delete GWT module development mode?

I have a GWT application with several modules. I have deleted one that I don't need anymore (JasperReportTest) - I deleted JasperReportTest.gwt.xml file and classes referring to that module.
But when I try to run my application in development mode I get this in my console:
Loading modules
com.mycompany.myapp.JasperReportTest
[ERROR] Unable to find 'com/mycompany/myapp/JasperReportTest.gwt.xml' on
your classpath; could be a typo, or maybe you forgot to include a
classpath entry for source?
If I run compile everything works fine. How can I delete the module, so development mode won't try to load it? I searched project for string "JasperReportTest" and I didn't find it. Where is loading of this module written?
Solved - problem was that in Run configurations I had that module in startup command
Have a look at the Google → Web Toolkit in your project's properties.
I was getting the same behaviour, and the good place to remove the reference to the unwanted module is in "run configuration" dialog but in the "arguments" tab', not in GWT one.

GWT tries to load a deleted module

I am using Eclispe with Google plugin for AppEngine and GWT. Recently I created a test GWT module, but eventually it has been deleted from the project and I can not find any sign of it in the project now.
However, whenever I run the web app locally, I get in console the following message:
Loading modules
com.piq.exemity.Test
[ERROR] Unable to find 'com/XXXXXX/Test.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
Has anyone got any idea where it can be hiding?
Open Run Configurations... from the Run pulldown menu and go to tab Arguments. In the Program arguments box delete the path to your deleted module.
It could be there in two places -
When you invoke GWTC (via the compile option in Eclipse), the module name com.xxx.Test is passed to the compiler. This causes GWT to look for com/xxx/Test.gwt.xml file
You could have a module that inherits the module "com.xxx.Test". Check your gwt.xml file if this is the case
I think (1) is more likely the culprit.