Intermittent NoClassDefFoundError when running a maven/surefire build in jenkins

后端 未结 4 1784
天涯浪人
天涯浪人 2021-02-04 06:24

We are building a large multi module Maven project on Jenkins, including running a large number of unit test.

Once every few builds the build fails on NoClassDefF

4条回答
  •  深忆病人
    2021-02-04 06:53

    Try running the maven build without the -T 4.

    The parallel builds feature in Maven 3 is still in the experimental stages, and it appears that there are known issues with thread safety in the plexus-utils library prior to version 2.0.5 - you're using version 1.5.1.

    Edit:

    Your problem is this dependency:

            
                org.apache.maven.surefire
                surefire-junit47
                ${testing.surefire.version}
            
    

    surefire-junit47 depends on maven-surefire-common, which in turn depends on maven-artifact, which depends on plexus-utils-1.5.1. As stated above, this has known thread safety issues, which is likely what is causing your problems. I'm not sure what parts of the surefire-junit47 library you're using, but if switching to surefire-junit4 is an option, then that should solve your problem.

    After looking at the docs for the surefire plugin a little more, it looks like you need the surefire-junit47 provider to run parallel tests. I'd try overriding plexus-utils to be version 2.0.5 and see if that works; otherwise, you can override the maven-artifact version to 3.0.3 or higher and see if that works.

提交回复
热议问题