I'm trying to run my junit test (to verify that a properties file loads correctly) but
I get ClassNotFoundException
although the class is there and all required libraries are there too.
Here it is the error I get :
Class not found ConfigurationManagerTest java.lang.ClassNotFoundException: ConfigurationManagerTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
any ideas on how to fix this ?
Thanks.
ConfigurationManagerTest
is not being found on your classpath. Ensure that the ConfigurationManagerTest.class
file is available on your classpath.
It might not exist if it wasn't successfully compiled or if it's being created in a directory that you haven't told the Eclipse project should be on the classpath.
Assuming that you've put your test classes in a separate folder, make sure that it shows up in the "Package Explorer" view (rather than the "Navigator" view).
Under the project properties, "Java Build Path" and the "Source" tab, you can also see if the source folder is included for building as well as where the .class files are generated.
There is one more possibility. I had the same problem just now and no one of the solutions here helped. Except removing and recreating of the project - I didn't want to try it. What did help, was to clean the project two times immediately one after another! Clean + build could be repeated any number of times - it won't help. Only clean+clean and after that build goes OK. (Eclipse 3.6). Of course, you should disable autobuild for that.
Edit: This post has got its last plus on 15.11.2017. So, the problem (and the solution) remains actual.
Another possible problem is a missing builder (it will prevent from your .class file from being built).
Check that your .project file has the following lines
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
This happened to me when I was dragging and dropping test classes to different packages. I just did the following
Bingo! I can now run the test!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With