I'm using Maven 2.0.1
I have a top-level pom.xml (<packaging>pom</packaging>) which builds 2
modules.  Module A has only external dependencies.  Module B has
external dependencies, but is also dependent on Module A.  Module B uses
a class from Module A in java source compilation, as well as in a unit
test.

Running "mvn test" from the top level results in success.
Running "mvn package" from the top level results in a
java.lang.NoClassDefFoundError during the unit test of Module B.

Using the -e and -X flags, I can see that during the "mvn -e -X test"
run, the Test Classpath for Module B contains: moduleA/target/classes,
and this is the case where no error occurs.
For the "mvn -e -X package" run, the Test Classpath for Module B
contains: moduleA/target/moduleA-1.0-SNAPSHOT.jar, and the class in
question is in there with the correct path.  This is the point where my
head begins to spin.

Has anyone else seen this problem?  Or better yet, have a suggested
solution.

Here is a little additional information...
If I just do an "mvn install" on Module A, I get moduleA-1.0-
SNAPSHOT.jar in my local repo with no problem.  Then when I try to do a
"mvn test" only on Module B, I get the same NoClassDefFoundError.  This
time the moduleA-1.0-SNAPSHOT.jar is put on the Test Classpath from my
local repo.  So "mvn test" works fine when building both modules
together via the parent pom, but not Module B by itself.  The similarity
seems to be when the moduleA-1.0-SNAPSHOT.jar is used (either from my
local repo, or from it's target directory), that's when I get the
NoClassDefFoundError.  Any insight would be greatly appreciated.

-Matt

Reply via email to