- This topic has 7 replies, 4 voices, and was last updated 15 years, 10 months ago by lynchdp.
-
AuthorPosts
-
Will Glass-HusainParticipantHi,
I’m getting ClassNotFoundExceptions when I run my Junit test from the IDE. I’ve read the sticky issue on this, it recommends to check the output directory is in the standard target location.
However, this is a Web project, and the output directory is webapps/WEB-INF/classes. Any advice on resolving this problem? I’m guessing the junit test from within the IDE is not finding this location.
One idea I had is to remove the Maven capability from this project– how can I do this?
cherngjeMemberIt’s sad to say that MyEclipse’s maven feature and web project doesn’t play nice with each other (due to how MyEclipse and maven each use different ways to package and deploy). In our environment, we just use maven to do package and deploy (instead of using MyEclipse’s deploy feature). By doing this, we can modify the output folders of source folders to target/classes instead of WEB-INF/classes. That way, you can do anything you want with your web project under the IDE beside using MyEclipse to deploy.
allenparslowMemberWhich version of MyEclipse are you running and is your test class in src/test/java?
lynchdpMember@cherngje wrote:
It’s sad to say that MyEclipse’s maven feature and web project doesn’t play nice with each other (due to how MyEclipse and maven each use different ways to package and deploy). In our environment, we just use maven to do package and deploy (instead of using MyEclipse’s deploy feature). By doing this, we can modify the output folders of source folders to target/classes instead of WEB-INF/classes. That way, you can do anything you want with your web project under the IDE beside using MyEclipse to deploy.
Why is this still a problem in a GA release?
If the Maven2 integration with MyEclipse cannot handle something so basic as the ability to run Unit Tests, it is certainly not production ready and should only be available as a beta or trial product.
I’ve been fighting this problem for two days now and have basically reached the end of my patience.
Where can I modify the configuration of my workspace so that I can prevent Maven and MyEclipse from stepping on each other when resolving something so simple as the CLASSPATH?
If the answer is “nowhere” I’m ready to recommend to my team (and every other Java developer I know) that we abandon this product (so called) completely.
allenparslowMemberIs it possible for anyone to post a pom.xml or steps to reproduce this problem? I only observed this problem in the milestone releases of MyEclipse 7 (but not the GA).
Also note when applying the sticky’s workaround for MyEclipse 7M2, it is implied that you have a src/test/java folder and you are only redirecting that folder to target/test-classes (and leaving src/main/java pointed to src/main/webapp/WEB-INF/classes). On a side note there is a second reason why maven encourages the src/test/java folder: it is not packaged into a war when executing the mvn install command, which keeps your production artifacts free of testing clutter.
lynchdpMemberThis happened after specifying the output folder for my test source tree as “target/test-classes” and doing the same for my test resources tree.
There seems to be a problem with the Maven JDK setting. Even though I have specified a JDK external to MyEclipse, I see the following in the MyEclipse maven console when I select, “Project->Clean…”
2/6/09 7:38:16 AM MST: [ERROR] COMPILATION ERROR :
2/6/09 7:38:16 AM MST: [INFO] ————————————————————-
2/6/09 7:38:16 AM MST: [ERROR] Unable to locate the Javac Compiler in:
C:\Program Files\Genuitec\Common\binary\com.sun.java.jre.win32.x86_1.5.0.011\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.Yet, the test classes are still being compiled to the target/test-classes folder.
And I am able to run the Unit Test.
allenparslowMemberOh, that is not a ClassNotFoundException.
You need to change a value in the myeclipse.ini file (MyEclilpse 7.0GA):
-vm <<location of a java 1.5 jdk>>
note the -vm line needs to be on a separate line from the jdk path.
lynchdpMemberOh, that is not a ClassNotFoundException.
Clearly understood — although MyEclipse should honor the preferences setting for the Maven JDK. I shouldn’t have to change the JVM for all of MyEclipse.
This error gets in the way of completing any exercise which attempts to remedy the original problem: ClassNotFoundException .
After many trials (and many errors) I seem to have reached a workable solution, although I am thoroughly dissaponted with the poorly envisioned, weakly implemented Maven/MyEclipse integration.
As long as a person is very careful to configure the IDE source and output folders exactly the same as the corresponding Maven configuration, it seems to work. At least until you run a Maven Clean on the POM, which should probably trigger a Project Build in the IDE but apparently doesn’t.
I don’t understand why the source and output folders for the IDE can’t be determined from the POM file, similar to the way the IDE interprets the maven dependencies and sets up the project classpath appropriately. Changing one should update the other (IMHO).
-
AuthorPosts