- This topic has 5 replies, 3 voices, and was last updated 15 years, 11 months ago by Riyad Kalla.
-
AuthorPosts
-
cherngjeMemberThere 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.
Riyad KallaMembercherngie,
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.
allenparslowMemberThis issue looks like the same one that I’m observing: https://www.genuitec.com/forums/topic/myeclipse-7-0m2-maven-packaging-war-junit-don-t-execute/ [MyEclipse 7.0M2, maven packaging=war, JUnit don’t execute].
The temporary workaround proposed by cherngje worked for me also.
allenparslowMemberOne 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.
allenparslowMemberIn 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.
Riyad KallaMemberallenparslow, glad to hear it.
-
AuthorPosts