我有一个打包成耳朵的项目。过去一个月左右,系统测试已被禁用。我们重新打开它们并修复了测试失败和构建脚本的问题。我无法解决最新的问题:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project systemTest: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test: org/junit/runner/notification/RunListener
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.14.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/tomcat/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.14.1/maven-surefire-plugin-2.14.1.jar
[ERROR] urls[1] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.14.1/surefire-junit47-2.14.1.jar
[ERROR] urls[2] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit48/2.14.1/common-junit48-2.14.1.jar
[ERROR] urls[3] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit4/2.14.1/common-junit4-2.14.1.jar
[ERROR] urls[4] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit3/2.14.1/common-junit3-2.14.1.jar
[ERROR] urls[5] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.14.1/surefire-grouper-2.14.1.jar
[ERROR] urls[6] = file:/home/tomcat/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
[ERROR] urls[7] = file:/home/tomcat/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[8] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-java5/2.14.1/common-java5-2.14.1.jar
[ERROR] urls[9] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.14.1/maven-surefire-common-2.14.1.jar
[ERROR] urls[10] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-booter/2.14.1/surefire-booter-2.14.1.jar
[ERROR] urls[11] = file:/home/tomcat/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] urls[12] = file:/home/tomcat/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[13] = file:/home/tomcat/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[ERROR] urls[14] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-api/2.14.1/surefire-api-2.14.1.jar
[ERROR] urls[15] = file:/home/tomcat/.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 / junit / runner / notification / RunListener。整个项目使用maven构建,junit
作为测试依赖项包含在内。
据我们所知,除了构建服务器之外,完整构建可以在任何地方工作。第二个有趣的一点,在构建服务器上,当系统测试不包括在内并且系统测试在自己运行时工作正常时,一切都很好。只有在构建完整项目(包括系统测试)时才会出现此问题。
这是系统测试pom.xml
的相关部分
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>com/crowncastle/test/*Test.class</include>
<include>com/crowncastle/test/suite/*TestSuite.class</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ear${file.separator}src${file.separator}main${file.separator}application${file.separator}APP-INF${file.separator}classes</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}src${file.separator}main${file.separator}resources</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}target${file.separator}classes</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}target${file.separator}test-classes</additionalClasspathElement>
</additionalClasspathElements>
<forkMode>always</forkMode>
<argLine>-Xmx1024m -XX:MaxPermSize=512m</argLine>
<runOrder>alphabetical</runOrder>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkedProcessTimeoutInSeconds>900</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
更新
我想也许有junit
的旧版本可能会导致问题,所以我运行了mvn dependency:analyze
和mvn dependency:tree
,但唯一提到junit
的是{{1} },这是合适的版本。
更新 我们能够在测试构建服务器上复制问题。之前我没有提到开发人员工作站运行Windows 8而构建服务器是linux。所以它可能是一个Windows vs linux问题,但我看不到。
答案 0 :(得分:2)
问题是两个因素的结合:
首先,存在一个传递依赖问题(即hamcrest-core 1.1 - &gt; jmock 1.1.0 - &gt; JUnit 3.8.1),其中(在Maven的依赖树中)较旧的JUnit“更接近” systemTest模块(继承了版本依赖关系),JUnit的修订版3.8.1没有包含org.junit.runner.notification.RunListener。
其次,maven对<version>
标签的解释存在混淆 - <version>4.10</version>
表示对junit的 soft 要求,而不是硬性要求(可能会显示为<version>[4.10]</version>
(另见Maven Dependency Mediation))
后者导致maven接受'最接近'令人满意的JUnit依赖(在本例中为3.8)而不是预期值,从而引起错误。将pom改为[N.mm]'hard'语法可以解决这个问题。
答案 1 :(得分:1)
我在重建开发环境时遇到了类似的问题。 少数罐子下载不正确。我能够继续从我的maven存储库中删除问题文件夹。这迫使maven再次下载它们,然后它们没有问题地工作。
在这种情况下,我删除了:
{local_repo} \组织\阿帕奇\行家\插件\行家-万无一失-插件