You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Alan D. Cabrera" <li...@toolazydogs.com> on 2008/07/22 00:26:36 UTC

java.lang.NoClassDefFoundError when running a test

I'm getting a java.lang.NoClassDefFoundError when running a test and  
yet, the code compiles fine.  Any ideas as to what's going on?  The  
exact same code compiles and test fine on another box which has the  
same mvn and java version.

There are no differences between 'mvn help:effective-settings' and/or  
'mvn help:effective-pom' and the artifact a jar that was downloaded  
contains the class; which makes sense because how else can the code  
compile.

I am stumped.


Regards,
Alan

Re: java.lang.NoClassDefFoundError when running a test

Posted by Tobias Gierke <to...@code-sourcery.de>.
Hi,
>
>
> and somehow the classpath contained only the test-jar dependeny when 
> the tests were executed. I think this is bug 
> http://jira.codehaus.org/browse/MNG-1971. Since there seems to be no real
Sorry, that's most likely not the right bug -  still quite early here in 
Germany ;) If I recall correctly , in my case the NoClassDefFound 
exception occured while the surefire plugin was looking for "testXXX" 
methods using reflection.

Regards,

Tobias
> work-around I just removed the <type>test-jar</type> from the dependency.
>
> Regards,
>
> Tobias
>
>>
>> There are no differences between 'mvn help:effective-settings' and/or 
>> 'mvn help:effective-pom' and the artifact a jar that was downloaded 
>> contains the class; which makes sense because how else can the code 
>> compile.
>>
>> I am stumped.
>>
>>
>> Regards,
>> Alan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: java.lang.NoClassDefFoundError when running a test

Posted by Tobias Gierke <to...@code-sourcery.de>.
>
> <dependency>
>  <groupId>X</groupId>
>  <artifactId>Y</artifactId>
>  <version>Z</version>
> </dependency>
> <dependency>
>  <groupId>X</groupId>
>  <artifactId>Y</artifactId>
>  <version>Z</version>
>  <type>test-jar</type>
My example was of course incomplete, I had

      <scope>test</scope>

on the test-jar dep.

Regards,

Tobias
> </dependency>
>
> and somehow the classpath contained only the test-jar dependeny when 
> the tests were executed. I think this is bug 
> http://jira.codehaus.org/browse/MNG-1971. Since there seems to be no 
> real work-around I just removed the <type>test-jar</type> from the 
> dependency.
>
> Regards,
>
> Tobias
>
>>
>> There are no differences between 'mvn help:effective-settings' and/or 
>> 'mvn help:effective-pom' and the artifact a jar that was downloaded 
>> contains the class; which makes sense because how else can the code 
>> compile.
>>
>> I am stumped.
>>
>>
>> Regards,
>> Alan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: java.lang.NoClassDefFoundError when running a test

Posted by Tobias Gierke <to...@code-sourcery.de>.
Hi,
> I'm getting a java.lang.NoClassDefFoundError when running a test and 
> yet, the code compiles fine.  Any ideas as to what's going on?  The 
> exact same code compiles and test fine on another box which has the 
> same mvn and java version.
I recently ran across the same issue. My pom.xml contained two dependencies

<dependency>
  <groupId>X</groupId>
  <artifactId>Y</artifactId>
  <version>Z</version>
</dependency>
<dependency>
  <groupId>X</groupId>
  <artifactId>Y</artifactId>
  <version>Z</version>
  <type>test-jar</type>
</dependency>

and somehow the classpath contained only the test-jar dependeny when the 
tests were executed. I think this is bug 
http://jira.codehaus.org/browse/MNG-1971. Since there seems to be no 
real work-around I just removed the <type>test-jar</type> from the 
dependency.

Regards,

Tobias

>
> There are no differences between 'mvn help:effective-settings' and/or 
> 'mvn help:effective-pom' and the artifact a jar that was downloaded 
> contains the class; which makes sense because how else can the code 
> compile.
>
> I am stumped.
>
>
> Regards,
> Alan


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org