maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Rosenvold <kristian.rosenv...@gmail.com>
Subject Re: surefire classpath problems with maven 3 parallel
Date Wed, 19 Jan 2011 07:57:08 GMT
Den 18.01.2011 18:03, skrev fmeili:
a)
The symptoms you are encountering seem to indicate that you're getting 
testng or junit3 in somewhere on your
classpath. As to why this is happening, we'll have to try some detective 
work:

The most significant difference between serial and parallel maven 
run-mode is that in serial, the entire
run-order of the reactor is defined up-front. In parallel, it isn't. 
Technically parallel mode knows a range of *possible* run-orders that
are described by the dependencies in the poms of your individual 
modules. So from build to build the run-order of your modules can
change somewhat. If module number 36 for some reason decides to spend 
twice as much time as usual, it could change the
build order of the remaining build more or less completely (although 
it'll normally not be *that* bad).

So mvn dependency:analyze is your friend here. Especially the "used, 
undeclared" dependencies might be able to introduce non-determinisms
into your parallel build.

A few more questions to ask:
- Although it fails intermittently, does it always fail on the same set 
of modules ?
- Does supressing transitive junit3/testng inclusions help ?

Surefire stores the fork-configuration for the test run in the 
target/surefire folder, and if you "grep" for the correct files
you should also be able to compare the values used for a 
successful/failing run. This would be really valuable.
(/me kicks myself in the leg for not making those property files 
alphabetical for the 100th time. Create an issue if you feel the same ;)

b)
This may actually be caused by somehow picking up testng/junit3 (ref 
problem A), especially if you're forcing surefire to use
the 4.7 provider. It's probably some behavioural change related to 
http://jira.codehaus.org/browse/SUREFIRE-663,
although I am not entirely sure of what would cause it.

Kristian


> 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


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


Mime
View raw message