Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] NoClassDefFoundError when unit test run via M2E but works fine on command line (the missing class should come from a project with package type 'war')

Hi all,

I get a NoClassDefFoundError if I run a test via M2E. When I run the same test from the command line (via mvn clean install) everything is fine. Is this a M2E bug?

The class that is missing comes from a project with package type 'war'.

This is what I declare in the pom.xml that contains the unit test:


This is what I declare in the pom.xml that provides the class:


The projects and the unit test that reproduce the problem are attached.

My environment:

m2e - Maven Integration for Eclipse - m2e Maven Integration for WTP JBoss by Red Hat

project-m2e-test-runtime-classpath>mvn --version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: C:\java\apache-maven-3.0.3
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_21\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

In Eclipse / Window / Preferences / Maven / Installations the embedded installation is chosen. Switching to the external Maven installation does not make a difference for the unit test.

The entire stacktrace of the error:

java.lang.NoClassDefFoundError: com/example/projectM2eTestRuntimeClasspath/projectA/MyClassA at com.example.projectM2eTestRuntimeClasspath.projectB.MyClassATest.testMyClassA(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall( at at org.junit.runners.model.FrameworkMethod.invokeExplosively( at org.junit.internal.runners.statements.InvokeMethod.evaluate( at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored( at org.junit.runners.BlockJUnit4ClassRunner.runChild( at org.junit.runners.BlockJUnit4ClassRunner.runChild(
    at org.junit.runners.ParentRunner$
    at org.junit.runners.ParentRunner$1.schedule(
    at org.junit.runners.ParentRunner.runChildren(
    at org.junit.runners.ParentRunner.access$000(
    at org.junit.runners.ParentRunner$2.evaluate(
at at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

Description: Binary data

Back to the top