Java 分叉的 VM 没有说再见就终止了。VM 崩溃或 System.exit 调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23260057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 21:33:18  来源:igfitidea点击:

The forked VM terminated without saying properly goodbye. VM crash or System.exit called

javamaven-surefire-pluginopendaylight

提问by astack

Please help me to solve this issue. I do not exactly understand what the error in the log means.

请帮我解决这个问题。我不完全明白日志中的错误是什么意思。

[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

回答by agudian

This part of the Surefire FAQcould help you:

Surefire 常见问题的这一部分可以帮助您:

Surefire fails with the message "The forked VM terminated without properly saying goodbye"

Surefire does not support tests or any referenced libraries calling System.exit() at any time. If they do so, they are incompatible with surefire and you should probably file an issue with the library/vendor. Alternatively the forked VM could also crash for a number of reasons, which can also make this issue happen. Look for the classical "hs_err*" files indicating VM crashes or examine the log output from running maven when the tests execute. Some "extraordinary" output from crashing processes may be dumped to the console/log. If this happens on a CI environment and only after some time runs there is a fair chance your test suite is leaking some kind of OS-level resource that makes things worse for every run. Regular os-level monitoring tools may give you some indication.

Surefire 失败并显示消息“分叉的 VM 没有正确说再见就终止了”

Surefire 不支持任何时候调用 System.exit() 的测试或任何引用库。如果他们这样做,它们与surefire不兼容,您可能应该向图书馆/供应商提出问题。或者,分叉的 VM 也可能由于多种原因崩溃,这也可能导致此问题发生。查找指示 VM 崩溃的经典“hs_err*”文件,或在测试执行时检查运行 maven 的日志输出。崩溃进程的一些“异常”输出可能会转储到控制台/日志。如果这种情况发生在 CI 环境中,并且只有在运行一段时间后,您的测试套件很可能会泄漏某种操作系统级别的资源,从而使每次运行的情况变得更糟。常规的操作系统级监控工具可能会给你一些指示。

回答by Chintan Patel

May be it is because you have applied some changes in your project and did not update their all references.

可能是因为您在项目中应用了一些更改并且没有更新它们的所有引用。

In my case I was getting this error because I have updated package names in my project but I forgot to update their references in TestNG.xml file. By correcting it, I solved this error.

在我的情况下,我收到此错误是因为我在我的项目中更新了包名称,但我忘记更新它们在 TestNG.xml 文件中的引用。通过纠正它,我解决了这个错误。

回答by user3509467

for me it worked with

对我来说,它与

mvn clean install -DskipTests -e

回答by Naresh Singh

You need to check if your machine is 64 bit or 32bit. If your machine is 32 bit then your memory argument should not exceed 4096, even it should be below 4 GB. but if your machine is 64 bit then, install Java 64 bit and provide JAVA_HOME in mvn.bat which point to java 64 bit installation.

您需要检查您的机器是 64 位还是 32 位。如果您的机器是 32 位,那么您的内存参数不应超过 4096,即使它应该低于 4 GB。但是如果你的机器是 64 位,那么安装 Java 64 位并在 mvn.bat 中提供 JAVA_HOME 指向 java 64 位安装。

回答by user2812481

I experienced this error after a static member variable in my test class called a method to create an object (which was used in test cases throughout the class), and the method caused an exception.

在我的测试类中的静态成员变量调用创建对象的方法(在整个类中的测试用例中使用)之后,我遇到了这个错误,并且该方法导致了异常。

// 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>

Some fixes include recreating the object inside each test case and catching any exceptions accordingly. Or by initializing the object inside an @BeforeTest method and ensuring that it is built properly.

一些修复包括在每个测试用例中重新创建对象并相应地捕获任何异常。或者通过在 @BeforeTest 方法内初始化对象并确保它正确构建。

回答by javabeangrinder

I had the same issue today and for me the real problem was reported further up in the log with message Cannot use a threadCount parameter less than 1; 1 > 0. When adding <threadCount>1</threadCount>in the surefire-plugin config the other error disappeared.

我今天遇到了同样的问题,对我来说,真正的问题在日志中进一步报告了消息Cannot use a threadCount parameter less than 1; 1 > 0。添加<threadCount>1</threadCount>surefire-plugin配置时,其他错误消失了。

完整的插件配置:
        <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>

...and yes, I am using both junit and testng in this test framework for backward compatibility reasons.

...是的,出于向后兼容性的原因,我在此测试框架中同时使用了 junit 和 testng。

回答by xiaohuo

I had the same problem and solved by adding:

我遇到了同样的问题并通过添加解决了:

<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>

The whole plugin element is:

整个插件元素是:

<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>

回答by thiago-devel

In my case, the issue was related to workspace path which was to much long. So I did a path refactoring and this solved the issue to me.

就我而言,该问题与工作区路径太长有关。所以我进行了路径重构,这解决了我的问题。

回答by erik.weathers

When I encountered this error it was due to my ulimit for open files (ulimit -n) being too low. It had (somehow) got set to only 256:

当我遇到这个错误时,是因为我打开文件的 ulimit ( ulimit -n) 太低了。它(以某种方式)设置为仅 256:

% ulimit -n
256

The error went away after I increased the limit:

增加限制后错误消失了:

% ulimit -n 3072
% ulimit -n     
3072

Your system might not allow the limit to be set so high. e.g., this happens when I try to use a larger number:

您的系统可能不允许将限制设置得如此之高。例如,当我尝试使用更大的数字时会发生这种情况:

% ulimit -n 3073
ulimit: setrlimit failed: invalid argument

Or this might be lower than your existing limit and you could be facing a different root cause.

或者这可能低于您现有的限制,并且您可能面临不同的根本原因。

回答by Chad Van De Hey

If anyone is including a custom argLine argument, you must reconsider because it is likely the source of your issues with the memory allocation.

如果有人包含自定义 argLine 参数,您必须重新考虑,因为它可能是您的内存分配问题的根源。

For Example (I used to have):

例如(我曾经有过):

<argLine>XX:MaxPermSize=4096m ${argLine}</argLine>

Now I use hard specified values:

现在我使用硬指定值:

<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>

For whatever reason, Applications that integrate with Surefire such as Jacoco, dont request enough memory to coexist with the testing that happens at build time.

无论出于何种原因,与 Surefire 集成的应用程序(例如 Jacoco)都不会请求足够的内存来与构建时发生的测试共存。