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

[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

当前回答

使用maven surefire 2.21.0我解决了reuseForks选项值从true变为false的问题:

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

我正在构建的整个配置部分是这样的:

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

其他回答

我的设想是

我的测试有很多日志输出(我的意思是很多!) Surefire插件v2.22.2 错误只发生在IDE内部,如果从命令行执行mvn命令则不会发生。 没有迹象显示Surefire插件中的任何.dump文件或Java二进制中的传统hs_err崩溃文件。

对我来说,有两件事一直是解决方案(它们是替代方案):

不使用fork:设置Surefire插件属性forkcount = 0。 增加Surefire插件属性 forkedProcessExitTimeoutInSeconds从30秒变成300秒。插件文档说,如果这个超时被击中,你会看到错误消息有一个超时在fork。我没有看到这样的错误消息,但是它一直在修复这个问题以增加这个超时值。

您可能希望使用解决方案(2),因为分叉是可取的。

Why?

我的理论是,如果有大量的日志输出,那么在fork关闭时仍然需要进行大量的处理(特别是如果您在一个IDE中运行,该IDE捕获输出并可能为其窗口内容使用内存映射文件)。简而言之:在测试完成时,仍有大量文本等待转发到IDE中。30岁似乎还不够。

这也解释了为什么有些开发者能够发现问题,而有些开发者却不能。在测试结束时,剩下多少输出处理可能是cpu功率、磁盘速度等的函数。

如果我在这一点上是正确的-不能证明它-那么所有的建议,如重定向日志输出和降低日志级别都是IMO处理症状,而不是原因。

您可以设置java选项

SET JAVA_OPTS='-Xmx1024m' XX:+UseLoopPredicate

MVN清洁安装

可能是因为你在你的项目中应用了一些更改,没有更新他们所有的引用。

在我的情况下,我得到这个错误,因为我已经更新了包的名称在我的项目,但我忘记更新他们的引用在TestNG.xml文件。通过修正,我解决了这个错误。

关闭maven-surefile-plugin的useSystemClassLoader应该会有帮助

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

Surefire FAQ的这一部分可以帮助你:

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.