每隔几次构建,noClassDefFoundError在runlistener
上的构建就会失败,它位于unit JAR中。从下面的日志中可以看到,JUnit包含在类路径中。
这个错误似乎完全是随机出现的。
原木
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project taboola-svc: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.17
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/builder/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
[ERROR] urls[1] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
[ERROR] urls[2] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
[ERROR] urls[3] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
[ERROR] urls[4] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
[ERROR] urls[5] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
[ERROR] urls[6] = file:/home/builder/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
[ERROR] urls[7] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
[ERROR] urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
[ERROR] urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] urls[10] = file:/home/builder/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
[ERROR] urls[11] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
[ERROR] urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] urls[13] = file:/home/builder/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[14] = file:/home/builder/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[ERROR] urls[15] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
[ERROR] urls[16] = file:/home/builder/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.junit.runner.notification.RunListener
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project taboola-svc: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:167)
at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:163)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:127)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 13 more
Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:125)
... 14 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:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
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:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398)
at java.lang.Class.getConstructor0(Class.java:2708)
at java.lang.Class.getConstructor(Class.java:1659)
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:235)
at org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:113)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.java:512)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:277)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:169)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:967)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:831)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:729)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
... 14 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:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:97)
... 53 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :taboola-svc
clean install -P FastTests -DIsBuildSystem=1 -T 4 -X -e
来自父级pom.xml的相关部分
项目本身是一个多模块pom项目,父pom定义了附加的surefire定义。
....
<!-- Generic tests plugin for maven -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${testing.surefire.version}</version>
<configuration>
<systemPropertyVariables>
<startPortForDebug>${startPortForDebug}</startPortForDebug>
<surefireForkNumber>fork_${surefire.forkNumber}</surefireForkNumber>
<geoip.db.dir>${basedir}/../framework/target/</geoip.db.dir>
<java.awt.headless>true</java.awt.headless>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</systemPropertyVariables>
<!-- Use new JVM for each test -->
<parallel>classes</parallel>
<threadCount>1</threadCount>
<forkCount>${testing.forkCount}</forkCount>
<reuseForks>${testing.reuseFork}</reuseForks>
<useSystemClassLoader>${testing.useSystemClassLoader}</useSystemClassLoader>
<useManifestOnlyJar>${testing.useManifestOnlyJar}</useManifestOnlyJar>
<!-- Display extra information on exception prints -->
<useFile>true</useFile>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
<!-- Display extra information on exception prints -->
<useFile>false</useFile>
<!-- -->
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
<argLine>-XX:PermSize=128m -XX:MaxPermSize=512m -DIsBuildSystem=${is.build.system}</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${testing.surefire.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
</plugin>
....
<profile>
<id>FastTests</id>
<properties>
<testing.forkCount>0.5C</testing.forkCount>
<testing.reuseFork>false</testing.reuseFork>
<testing.useSystemClassLoader>true</testing.useSystemClassLoader>
<testing.useManifestOnlyJar>false</testing.useManifestOnlyJar>
</properties>
</profile>
尝试在不使用-t4
的情况下运行maven构建。
Maven3中的并行构建功能仍处于试验阶段,在2.0.5版之前的plexus-utils
库中似乎存在已知的线程安全问题-您使用的是1.5.1版。
编辑:
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${testing.surefire.version}</version>
</dependency>
我尝试用OpenJDK11在Jenkins中构建工件。首先,我运行了 但是,当我运行时,测试类出现了以下错误。 波姆。xml 请帮助我在詹金斯解决这个问题 注:我在当地也遇到了类似的问题。我在~/换了家。mavenrc文件
问题内容: 我有一个Java应用程序的Maven构建,可以通过键入相同的命令在Linux或Windows上成功运行。 然而,使用Jenkinsfile方法设置此生成,在Linux上文件需要包含和Windows 。 如果在Windows上正确配置了路径和工具,则日志显示: 有没有办法让单个Jenkinsfile允许在两种环境中构建? 问题答案: 管道脚本可以包含常规代码,因此允许分支。您可以使用并根
我是新来的詹金斯!我设法在Jenkins中克隆了GIT hub repo,现在试图在Jenkins中构建提取的maven项目。我从GITHUB获取了7个项目,它们相互依赖,也就是说,一些项目在其POM中为其他项目定义了依赖关系。 以下是我的maven配置(对不起,不能在这里张贴图片,见粗体) 根POM myFirstProject/POM.xml 目标和选项清洁包安装 MAVEN_OPTS 备用设
我在Windows7中有cygwin,下载并安装了maven“二进制文件”,并有以下设置 我错过了什么?
问题内容: 我正在使用Jenkins管道配置Android应用程序构建过程。 在构建的开始和结束时,将消息发送到相关的Slack通道。 Jenkinsfile的相关部分如下所示: 除了上述信息之外,我还想包括构建运行到该消息的时间,该消息通知构建结束。 是否可以在不添加任何外部插件的情况下做到这一点?如果有一个环境变量可以保存此信息,那将是完美的,但我找不到这样的变量。 问题答案: 由于此 jen
詹金斯的新成员。 目前,我们使用maven和Subversion作为SCM进行手动构建: > 在本地工作副本文件夹中,POM文件有1.1.1-SNAPSHOT,issue mvn release:clean release:prepare-p all modules 这将创建一个标记https://avn/path/to/tag/xxx-1.1.1,而我的本地工作副本仍在1.1.2-SNAPSHO