请帮我解决这个问题。我不完全理解日志中的错误意味着什么。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.749s
[INFO] Finished at: Thu Apr 24 10:10:20 IST 2014
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project samples.simpleforwarding: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_55\jre\bin\java" -Xmx1024m -XX:MaxPermSize=256m -jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefirebooter53410321571238933.jar E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire86076271125218001tmp E:\OpenDayLight\controller\opendaylight\samples\simpleforwarding\target\surefire\surefire_01846991116135903536tmp"
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/PluginExecutionException
我有同样的问题,并通过添加:
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
整个插件元素是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
关闭maven-surefire-plugin的useSystemClassLoader应该有所帮助
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
我在Jenkins Docker容器中遇到了这个问题(尝试过jenkins:lts,jenkins,jenkins:slim和jenkins:slim-lts。我不想浏览所有存储库并更新每个项目的pom,所以我刚刚将disableClassPathURLCheck添加到maven命令行调用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
您需要检查您的机器是64位还是32位。如果您的机器是32位,那么您的内存参数不应超过4096,即使它应低于4 GB。但如果你的机器是64位,那么安装Java 64位并在mvn.bat中提供JAVA_HOME,这指向java 64位安装。
我最近在使用Bamboo构建容器化jar应用程序时遇到了这个错误:
org.apache.maven.surefire.booter.SurefireBooterForkException:分叉的VM在没有正确说再见的情况下终止
经过几个小时的研究,我修好了它。我认为在这里分享我的解决方案会很有用。
因此,每当Bamboo运行mvn test -DargLine="-Djdk.net.URLClassPath.disableClassPathURLCheck=true"
命令为docker容器中的java应用程序时,就会发生错误。我不是Maven的专家,但麻烦在于Surefire和Junit4插件包含在spring-boot中作为maven依赖。
要修复它,你需要替换Junit5的Junit4并覆盖mvn clean package
中的Surefire插件。
1.Inside spring boot依赖项插入排除:
pom.xml
2.添加新的Junit5依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- FIX BAMBOO DEPLOY>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
<!---->
</dependency>
3.在插件部分插入新插件
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
这应该足以修复竹子建筑。不要忘记转换所有Junit4测试以支持Junit5。
我遇到了一个案例,当时提供的答案都没有解决问题。它是遗留应用程序,恰好使用log4j和SLF4J / logback。
以前的情况:从Eclipse中启动时,<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</plugin>
构建运行正常,但是在命令行中启动时,发生了此错误。基于CircleCI构建的CI也运行良好。
我做了什么:出于纯粹的猜测,配置一个合适的clean test
并拨下日志记录的详细程度。瞧,我不再遇到这个错误,我现在可以从命令行构建项目(以及发生此错误的模块)。
我的观点是,使用或配置日志框架的方式可能是另一种解释。
它真的是log4j和logback之间的冲突吗?或者只是测试产生的大量日志记录以某种方式溢出命令行缓冲区?我不知道。这对我来说仍然是一个谜。
在pom.xml中设置它对我有用。但是你应该查看其他解决方法logback-test.xml
的文档
https://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html
使用maven surefire 2.21.0我解决了将 <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--these strange settings fixes a chrash and dumpstream from surefire when run from command line
Caused by: java.lang.ClassNotFoundException: org.apache.maven.surefire.booter.ForkedBooter
-->
<useSystemClassLoader>true</useSystemClassLoader>
<useManifestOnlyJar>false</useManifestOnlyJar>
</configuration>
</plugin>
选项值从true更改为false的问题:
reuseForks
我在构建下的整个配置部分看起来像:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
我在Jenkins构建Ubuntu机器时遇到了这个问题。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<skip>false</skip>
<reuseForks>false</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<argLine>-Dfile.encoding=UTF-8</argLine>
<useSystemClassLoader>false</useSystemClassLoader>
<includes>
<!--Test* classes for the app testing -->
<include>**/directory/Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
报道了/var/log/syslog
。
Out of memory: Kill process 19557 (java) score 207 or sacrifice child
。从那时起,问题就消失了。
您可以设置java选项
I therefore gave the Ubuntu machine more swap space
SET JAVA_OPTS='-Xmx1024m' XX:+UseLoopPredicate
在Windows(OpenJDK11,Maven 3.6.0,SUREFIRE 3.0.0-M1)上,我找到了根本原因:
mvn clean install
并通过增加页面文件大小来解决,例如# Created at 2018-11-14T14:28:15.629
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006c7500000, 522190848, 0) failed; error='The paging file is too small for this operation to complete' (DOS error/errno=1455)
。
截至今天(10/30/2018),我们注意到我们的构建在Jenkins中出现了这个错误。
该错误有点误导,需要查看target/surefire-reports/
中转储的输出,以查看以下错误消息:
Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter
这让我想到了以下SO帖子,其中提到了OpenJDK 181中可能存在的错误:Maven surefire could not find ForkedBooter class
该帖子中的任何一个修复程序都解决了我的问题。具体来说,我使用其中一个:
maven:3.5.4-jdk-8
中的建筑物切换到maven:3.5.4-jdk-8-alpine
我遇到了同样的问题,通过使用Oracle的Java 8而不是Openjdk的Java 10解决了这个问题
测试中使用的分叉JVM内存不足。解决方案是禁用分支JVM并在主JVM上运行测试,确保您有足够的内存或传递args以增加分叉JVM的内存
查看此this中的解决方案
我尝试了所有提供的解决方案(分叉,系统加载器,更多内存等),没有任何效果。
环境:在gitlab ci环境中构建失败,在docker容器内运行构建。
解决方案:我们在版本2.20.1中使用surefireplugin并升级到2.21.0或更高版本(我们使用2.22.1)修复了该问题。
原因:qazxsw poi - surefire使用命令qazxsw poi,这在docker环境中不可用并导致“崩溃”。此问题已在2.21.0或更高版本中修复。
感谢另一个问题的回答:answer
在我的测试类中的静态成员变量调用创建对象的方法(在整个类中的测试用例中使用)之后,我遇到此错误,并且该方法导致异常。
SUREFIRE-1422
一些修复包括在每个测试用例中重新创建对象并相应地捕获任何异常。或者通过在@BeforeTest方法中初始化对象并确保它正确构建。
在我的例子中,问题与工作空间路径有关,这段时间很长。所以我做了一个路径重构,这解决了我的问题。
当我遇到这个错误时,这是由于我的ulimit打开文件(ps
)太低了。它(以某种方式)设置为只有256:
https://stackoverflow.com/a/50568662/2970422
我增加限制后错误消失了:
// Object created inside test class by calling a static getter.
// Exception thrown in getter:
private static Object someObject = SomeObject.getObject(...);
// ... <Object later used in class>
您的系统可能不允许将限制设置得如此之高。例如,当我尝试使用更大的数字时会发生这种情况:
ulimit -n
或者这可能低于您现有的限制,您可能面临不同的根本原因。
在我的情况下,我忘了在pom中添加依赖项:
% ulimit -n
256
只需确保选择正确的版本(今天1.8.9是最新的)
我也经历过这个 - 但在我的情况下,我已经为黄瓜写了一个定制的钩子
% ulimit -n 3072
% ulimit -n
3072
...
我的一个方法是产生一个Null指针异常,它导致surefire退出而不记录错误。
最近travis杀死了测试的执行(没有改变任何相关的东西(以及在开发者机器上的成功构建!)),因此BUILD FAILURE。其中一个原因是这个(见@agudian答案):
Surefire不支持测试或任何调用System.exit()`的引用库
(因为测试类确实称为% ulimit -n 3073
ulimit: setrlimit failed: invalid argument
)。
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.5</version>
</dependency>
语句代替帮助。public class MappingFormatter implements gherkin.formatter.Formatter {
)。 (另外,我必须删除System.exit(-1)
才能在我的桌面上构建)只做两件事中的一件并没有奏效。
有关更多背景,请阅读return
。
由于完全不同的问题,这也可能发生。例如,在我的情况下,我们的Jenkins构建在没有任何理由的情况下执行测试时间歇性地失败。
我筛选了我们的测试,发现任何<argLine>
的发生,但没有。
在进行了更多的挖掘后,我发现这可能会发生,因为JDK错误可能导致这种回归。
-XX:MaxPermSize=256m
我仍在努力在我们的构建中进行此修复,将返回并再次更新该线程。
我有类似的问题(Maven build and maven-failsafe-plugin - The forked VM terminated without properly saying goodbye),并找到了三个适合我的解决方案:
问题是maven插件maven-surefire-plugin仅在版本2.20.1和2.21.0中。我检查过你使用版本2.20.1。
将插件版本升级到2.22.0。在pom.xml中添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
将插件版本降级到2.20。在pom.xml中添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
</plugin>
使用插件配置testFailureIgnore。在pom.xml中添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
这可能是由于内存不足造成的。运行mvn时,请确保没有任何应用程序在后台运行。就我而言,Firefox在具有高内存使用率的后台运行。
在我的情况下,问题与太长的日志输出到IntelliJ IDEA控制台(OS窗口10)有关。 命令:
mvn clean install
这个命令解决了我的问题:
mvn clean install > log-file.log
这部分Surefire FAQ可以帮助你:
Surefire失败并显示消息“分叉的虚拟机在没有正确说再见的情况下终止”
Surefire不支持随时调用System.exit()的测试或任何引用库。如果他们这样做,他们与surefire不兼容,你可能应该向库/供应商提出问题。或者,分叉的VM也可能由于多种原因而崩溃,这也可能导致此问题发生。查找表示VM崩溃的经典“hs_err *”文件,或者在测试执行时检查运行maven的日志输出。崩溃进程的一些“非常”输出可能会被转储到控制台/日志中。如果这种情况发生在CI环境中并且仅在一段时间后运行,那么您的测试套件很可能会泄漏某种操作系统级别的资源,这会使每次运行都变得更糟。常规的os级监控工具可能会给你一些指示。
刚刚面临同样的问题,ubuntu上的java 8
然后遇到了https://stackoverflow.com/a/53016532/1676516
这似乎是一个最新的插件版本2.22.1与java 8 https://issues.apache.org/jira/browse/SUREFIRE-1588的错误
通过当地maven设置qazxsw poi遵循建议的解决方法
~/.m2/settings.xml
我今天遇到了同样的问题,对我来说,真正的问题是在日志中用<profiles>
<profile>
<id>SUREFIRE-1588</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</properties>
</profile>
</profiles>
消息进一步报道的。在surefire-plugin配置中添加Cannot use a threadCount parameter less than 1; 1 > 0
时,其他错误消失了。
<threadCount>1</threadCount>
...是的,我在这个测试框架中使用junit和testng是出于向后兼容的原因。
在JDK 1.8.0_65上使用Jacoco插件运行mvn命令时遇到类似问题
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<configuration>
<threadCount>1</threadCount>
</configuration>
</plugin>
JDK [INFO]
A fatal error has been detected by the Java Runtime Environment:
JRE version: Java(TM) SE Runtime Environment (8.0_65-b17) (build 1.8.0_65-b17).........
Problematic frame:
PhaseIdealLoop::build_loop_late_post(Node*)+0x144
............
............
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project
The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
中有一个错误
解决方案是使用param -XX:-UseLoopPredicate运行mvn clean install
或者只是对JDK进行更新(我认为较新的次要版本有效)
如果有人包含自定义argLine参数,则必须重新考虑,因为它可能是内存分配问题的根源。
例如(我以前):
https://bugs.openjdk.java.net/browse/JDK-8081379
现在我使用硬指定值:
<argLine>XX:MaxPermSize=4096m ${argLine}</argLine>
无论出于何种原因,与Socofire集成的应用程序(如Jacoco)不要求足够的内存与构建时发生的测试共存。