Hi,
while migrating to maven 3 (a large multi module project with >200 maven
projects) I ran into a lot of surefire JUnit problems. The whole project
builds correct with maven 3 serial build (without -T option).
I've isolated problematic tests and for them I use the surefire
configuration <forkMode>always</forkMode>. This solved my System-property
based parts of my projects so I'm generally able to build/test in parallel.
But I still have some strange ClassNotFound exceptions in parallel mode for
my JUnit tests. There are two different problems:
a)
While the JUnit tests are running it can't find any of the org.junit classes
(e.g. After, Befor, TestCase,...) and complains with a ClassNotFound for
them. I think I use the right dependencies in my projects root pom,
specified in the <dependencyManagement> section:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.8.2</version>
</dependency>
</dependencies>
</dependencyManagement>
The errors looks like this:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile
(default-testCompile) on project qm-server: Compilation failure: Compilation
failure:
[ERROR]
/Daten/projects/qq/server/src/test/java/aaa/bbb/TestXYBean.java:[11,23]
package org.junit does not exist
[ERROR]
/Daten/projects/q/server/src/test/java/aaa/bbb//TestXYConfigBean.java:[15,3]
cannot find symbol
[ERROR] symbol : class Test
...
b)
The other problem occures for projects which doesn't have test classes until
yet (no JUnit tests in the src folder). But the surefire plugin try to
execute this (none existing tests) and this results in the following error:
------------------------------------------------------- T E S T
S-------------------------------------------------------
Concurrency config is parallel='none', perCoreThreadCount=true,
threadCount=2, useUnlimitedThreads=false
java.lang.reflect.UndeclaredThrowableException
at $Proxy0.invoke(Unknown Source)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
... 4 more
Caused by: java.lang.NoClassDefFoundError:
org/junit/runner/notification/RunListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
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)
at
org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:97)
... 9 more
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)
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.7.1:test (default-test) on
project xy-server: There are test failures.
[ERROR]
[ERROR] Please refer to/Daten/projects/xy/server/target/surefire-reports for
the individual test results.
[ERROR] -> [Help 1]
This message indicates that a /surefile-reports directory exists, but it
doesn't exist because there are no tests. But the surefire plugin created a
directory /surefire with some tmp-files.
All my projects (also the projects which don't have unit tests until now)
inherit the JUnit dependency from my project root pom specified in the
<dependencies> section of my project root pom:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Playing around with the following surefire configuration changes the
behavior but not reproducable, sometimes some errors gone and a build later
the above errors appear on other projects and so on.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<forkMode>always</forkMode>
<useSystemClassLoader>true</useSystemClassLoader>
<useManifestOnlyJar>false</useManifestOnlyJar>
</configuration>
</plugin>
Til now I have not found a configuration where I can build massive parallel
with maven 3.
Has someone an idea to bring this to work? I'm using Maven 3.0.2.
Thanks in advance,
fmeili
--
View this message in context:
http://maven.40175.n5.nabble.com/surefire-classpath-problems-with-maven-3-parallel-tp3346469p3346469.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]