MyEclipse: Potential solution to ClassNotFoundException

cherngje - Nov 10, 2008 - 02:11 PM
Post subject: Potential solution to ClassNotFoundException
There is (or was) an issue with Maven4MyEclipse when use IDE to run application or JUnit test. The problem that I encountered was that when I try to run application or JUnit test by using IDE tool, I got ClassNotFoundException, however, everything is fine when using "Maven Test". I can not remember the exact steps to recreate the problem, but the problem was most likely due to Java Build Path.

If you see your project has both target and target-eclipse, it is very likely you will run into this kind of problem. What you can do is right click on the project, and then select Properties, then go to "Java Build Path". In the menu, change the default output folder to ProjectName/target/classes. If your project follows standard structure, then the output folder for ProjectName/src/main/java should be changed to ProjectName/target/classes, and the output folder for ProjectName/src/test/java should be changed to ProjectName/target/test-classes. At this point, you can delete target-eclipse folder. One thing that I need to mention is that MyEclipse doesn't create web project that follows the standard maven structure. I always change the structure and pom to follow standard maven structure, so the above steps can apply to the web project as well.

After the Java Build Path is all set, you should be able to run maven clean follow by project/clean (with build automatically enabled), then you should be able run application/JUnit test from IDE.

Maven clean will delete target folder and all the generated class files, and project/clean (with build automatically enabled) will recreate the target folder with most up-to-dated classes files.

Hope this can help.
support-rkalla - Nov 10, 2008 - 04:33 PM
Post subject: RE: Potential solution to ClassNotFoundException
cherngie,

We really appreciate you taking the time to type up that solution for other folks that might be running into it (I'm stickying this thread for now). In the mean time I have forwarded the issue along to the product team for evaluation.
allenparslow - Nov 11, 2008 - 12:44 PM
Post subject: RE: Potential solution to ClassNotFoundException
This issue looks like the same one that I'm observing: http://www.myeclipseide.com/PNphpBB2-viewtopic-t-22045.html [MyEclipse 7.0M2, maven packaging=war, JUnit don't execute].

The temporary workaround proposed by cherngje worked for me also.
allenparslow - Nov 11, 2008 - 12:46 PM
Post subject: RE: Potential solution to ClassNotFoundException
Quote:

One thing that I need to mention is that MyEclipse doesn't create web project that follows the standard maven structure. I always change the structure and pom to follow standard maven structure, so the above steps can apply to the web project as well.

I also agree.
allenparslow - Dec 11, 2008 - 01:50 PM
Post subject: RE: Potential solution to ClassNotFoundException
In MyEclipse 7.0 (release), I am able to run (from the IDE) test-classes in src/test/java with packaging-war without ClassNotFoundException without changing the java build path.

I think the issue has been resolved.
support-rkalla - Dec 16, 2008 - 06:34 PM
Post subject: RE: Potential solution to ClassNotFoundException
allenparslow, glad to hear it.
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits