Test-classified but compile-scoped dependency causes NoClassDefFoundError: org/junit/runner/notification/RunListener --------------------------------------------------------------------------------------------------------------------
Key: SUREFIRE-708 URL: http://jira.codehaus.org/browse/SUREFIRE-708 Project: Maven Surefire Issue Type: Bug Components: classloading, Maven Surefire Plugin Affects Versions: 2.7.2 Environment: Apache Maven 3.0.2 (r1056850; 2011-01-09 01:58:10+0100) Java version: 1.6.0_22, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x", version: "10.6.6", arch: "x86_64", family: "mac" Reporter: Andreas Sewe Priority: Blocker Attachments: pom.xml I have a real-world project which has a {{test}}-classified third-party dependency that is (out of necessity) {{compile}}-scoped rather then {{test}}-scoped (as the test-JAR unfortunately contains classes also useful outside of a testing context). This constellation causes the {{maven-surefire-plugin}} to fail with a {{NoClassDefFoundError}}, thus effectively preventing the project from being build: {quote} java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) at java.lang.Class.getConstructor0(Class.java:2699) at java.lang.Class.getConstructor(Class.java:1657) at org.apache.maven.surefire.util.ReflectionUtils.getConstructor(ReflectionUtils.java:76) at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:129) at org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:198) at org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:72) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:146) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:93) ... 11 more {quote} Attached is a minimal Maven project (just the POM; whether there are test sources present doesn't change the outcome) that reproduces this problem. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira