相关疑难解决方法(0)

Maven surefire无法找到ForkedBooter类

最近来到一个新项目,我正在尝试编译我们的源代码.昨天一切都很好,但今天是另一个故事.

每次我在mvn clean install模块上运行时,一旦到达测试,它就会崩溃成一个错误:

[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ recorder ---
[INFO] Surefire report directory: /lhome/code/recorder/target/surefire-reports
[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
[INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0,     threadCountClasses=0, threadCountMethods=0, parallelOptimized=true

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Run Code Online (Sandbox Code Playgroud)

后来:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project recorder: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated …
Run Code Online (Sandbox Code Playgroud)

java maven maven-surefire-plugin

210
推荐指数
10
解决办法
5万
查看次数

我们何时应该在Java中调用System.exit

在Java中,System.exit(0)以下代码有或没有区别?

public class TestExit
{      
    public static void main(String[] args)
    { 
        System.out.println("hello world");

        System.exit(0);  // is it necessary? And when it must be called? 
    }      
}
Run Code Online (Sandbox Code Playgroud)

文件说:"这种方法永远不会正常返回." 这是什么意思?

java exit

191
推荐指数
8
解决办法
34万
查看次数

有没有办法通过命令行将jvm args传递给maven?

可能重复:
maven jetty插件 - 如何控制vm参数?

特别是,我想做这样的事情:

mvn -DjvmArgs="-Xmx2000m -Xms1000m -XX:PermSize=512m -XX:MaxPermSize=512m" jetty:run -Pmyprofile
Run Code Online (Sandbox Code Playgroud)

哦,我想这样做而不必修改pom文件或设置任何环境变量等

java jetty maven

106
推荐指数
1
解决办法
13万
查看次数

Spring Boot无法运行maven-surefire-plugin ClassNotFoundException org.apache.maven.surefire.booter.ForkedBooter

运行maven(3.5.2)构建Spring Boot 2.0.2.RELEASE应用程序(由Web初始化程序生成,具有Web依赖性)无法执行maven-surefire-plugin说:

错误:无法找到或加载主类org.apache.maven.surefire.booter.ForkedBooter

引起:java.lang.ClassNotFoundException:org.apache.maven.surefire.booter.ForkedBooter

为什么会这样?这是boot + surefire集成中的一个问题=一个bug?

作为参考,似乎相关的依赖关系是:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath/>
</parent>
...
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
</dependency>
...
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
</dependency>
...
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

spring maven maven-surefire-plugin spring-boot

54
推荐指数
4
解决办法
2万
查看次数

调试surefire的策略"分叉的虚拟机终止而没有说再见.虚拟机崩溃或System.exit被调用?"

我正在开发一个相当复杂的java项目,它有许多依赖项和许多单元测试.

我在mac(mavericks)上使用java 1.6.0_65,使用maven 3.0.5和maven-surefire-plugin:2.16在几个forks中运行.我的问题是使用多个forks运行此设置会导致fork退出:

"分叉的虚拟机终止了,没有说再见.虚拟机崩溃或System.exit调用?"

只使用一个fork运行它不会产生问题(并且一切都通过)

有一些关于这个问题的信息包括这个StackOverflow问题这个万无一失的bug(现在似乎已经解决了)

我知道这种情况的"答案"是在我的代码中找到什么叫System.exit() - 我找不到任何东西.

或者是什么原因导致我的JVM崩溃 - 没有hs_pid崩溃报告.

我的问题是我可以用什么样的策略来找到找到这个原因的? 为了澄清,我对上面提到的答案不感兴趣,但是找到它的起源.(或者甚至更好地回答可能造成这种情况的不同答案)


我的Surefire配置是:(但我确实尝试过其他组合)

<parallel>classes</parallel>
<threadCount>1</threadCount>
<forkCount>1C</forkCount>
<reuseForks>false</reuseForks>
<useSystemClassLoader>false</useSystemClassLoader>
<useManifestOnlyJar>true</useManifestOnlyJar>
<useFile>true</useFile>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<runOrder>alphabetical</runOrder>
Run Code Online (Sandbox Code Playgroud)

在使用--debug(-X)运行maven目标后添加#1添加相关的输出

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project event-logger: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command was/bin/sh -c cd /Users/nitzan/work/nitzan_5_parallel_tests/event-logger && /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/bin/java org.apache.maven.surefire.booter.ForkedBooter /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire5107531798951225850tmp /Users/nitzan/work/nitzan_5_parallel_tests/event-logger/target/surefire/surefire_12561116468761732560tmp
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to …
Run Code Online (Sandbox Code Playgroud)

java maven maven-surefire-plugin

29
推荐指数
4
解决办法
3万
查看次数

如何获取Eclipse运行配置的命令行?

我在Eclipse中有几个JUnit运行配置,我需要在命令行上复制才能使用第三方分析工具.到目前为止,我刚刚通过查看运行配置并编写相应的类路径和命令行参数来手动编写命令行.

Eclipse的运行配置(普通,JUnit或其他)最终必须归结为命令行,那么我如何以及在何处找到它?

eclipse

17
推荐指数
1
解决办法
2万
查看次数

Docker-> Maven-> Failsafe-> Surefire启动分叉失败,"分叉的虚拟机没有正常说再见就终止了.虚拟机崩溃或System.exit被调用?"

按照标题:我正试图从容器化的詹金斯奴隶那里运行Maven自动化测试,并且经过一个星期的斗争,现在我已经没有想法了.它在具有4G RAM的AWS实例上工作,但在不受限制的(在RAM和CPU上)容器中,它失败并出现如下错误.它运行的唯一情况是我禁用Failsafe插件的分支,但这不是一个选项.

我尝试了各种各样的Java/Maven/Failsafe/Surefire选项,我可以用谷歌找到但没有运气(比如添加全局Java -Xmx选项以及pom.xml中的每个插件).

有没有人像这样成功地运行它?

这似乎应该更容易处理,但我现在已经拉了我头上的所有头发我应该有.我仍然不喜欢承认失败的想法.请帮忙!

这些是插件在失败后创建的转储:

故障安全-summary.xml:

<?xml version="1.0" encoding="UTF-8"?>
<failsafe-summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-sure
fire-plugin/xsd/failsafe-summary.xsd" result="254" timeout="false">
    <completed>0</completed>
    <errors>0</errors>
    <failures>0</failures>
    <skipped>0</skipped>
    <failureMessage>org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM cras
h or System.exit called?
Command was /bin/sh -c cd /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle &amp;&amp; /usr/lib/jvm/java-1.8-openjdk/jre/bin/ja
va -Dfile.encoding=UTF-8 -jar /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle/target/surefire/surefirebooter81206735832436906
05.jar /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle/target/surefire 2017-10-10T15-02-35_189-jvmRun1 surefire59539140137458
58339tmp surefire_03559885505222114015tmp
Error occurred in starting fork, check output in log
Process Exit Code: 1
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
       at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
       at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
       at …
Run Code Online (Sandbox Code Playgroud)

java containers maven maven-surefire-plugin docker

12
推荐指数
3
解决办法
6331
查看次数

JaCoCo在跳过JaCoCo执行之后才生成jacoco.exec

我在我的一个模块中通过JaCoCo生成AHP报告时遇到了麻烦.构建开始时,我看到JaCoCo正确设置了argLine:

[INFO] jacoco.agent.argLine set to -javaagent:<...>/.m2/repository/org/jacoco/org.jacoco.agent/0.7.2.201409121644/org.jacoco.agent-0.7.2.201409121644-runtime.jar=destfile=<...>/target/jacoco.exec
Run Code Online (Sandbox Code Playgroud)

但是,maven尝试运行JaCoCo时尚未创建.exec:

[INFO] Skipping JaCoCo execution due to missing execution data file:<...>/target/jacoco.exec
Run Code Online (Sandbox Code Playgroud)

在maven跳过JaCoCo执行后,jacoco.exec最终会被创建.因此,如果我在没有清理的情况下重新运行构建,我仍然可以生成AHP报告.

我已经在其他各种问题中看到,我需要小心使用Maven Surefire和JaCoCo.但是,我没有在我的Surefire插件或任何插件中明确使用argLine.我开始怀疑其他插件之一是否像JaCoCo一样自动劫持argLine参数.

以下是使用的所有插件的列表:

  • jacoco - Maven的插件
  • vertx - Maven的插件
  • Maven的资源 - 插件
  • Maven的依赖关系的插件
  • Maven的万无一失,插件
  • Maven的故障保护,插件
  • Maven的万无一失报告,插件
  • 行家组装-插件

我确实在构建输出中看到一条可疑消息:

[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ <module> ---
[INFO] Changes detected - recompiling the module!
Run Code Online (Sandbox Code Playgroud)

我不确定这是否相关,但它在跳过消息之前出现了两次,并且没有出现在JaCoCo正常工作的模块中.

有任何想法吗?

*编辑 - 这是jacoco配置

    <plugins>
        <...>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This …
Run Code Online (Sandbox Code Playgroud)

maven jacoco

11
推荐指数
3
解决办法
3万
查看次数

Maven build和maven-failsafe-plugin - 分叉的VM在没有正确说再见的情况下终止

我使用Docker和https://github.com/fabric8io/docker-maven-plugin进行集成测试.

在我的Windows 10(更新到Windows 10 1709之后)机器上,我的Maven 3.5.0构建面临以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project api: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projects\example\api\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "c:\Java\jdk1.8.0_152\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire1232565117555778729\surefirebooter3745527118196863348.jar C:\Users\Alexander\AppData\Local\Temp\surefire1232565117555778729 2017-10-19T16-45-23_780-jvmRun1 surefire4633356271541422594tmp surefire_169922891955689988tmp"
[ERROR] Error …
Run Code Online (Sandbox Code Playgroud)

java maven maven-surefire-plugin docker windows-10

9
推荐指数
2
解决办法
9159
查看次数

启动叉发生Maven错误,请在日志中检查输出

我使用Maven,docker-maven-plugin和Spring Boot。现在,我遇到以下问题:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:08 min
[INFO] Finished at: 2018-03-30T20:31:08+03:00
[INFO] Final Memory: 76M/1162M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.20.1:verify (default) on project domain: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projects\decisionwanted\domain\target\failsafe-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X …
Run Code Online (Sandbox Code Playgroud)

maven maven-surefire-plugin docker spring-boot windows-10

8
推荐指数
4
解决办法
6225
查看次数

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

我正在使用 geb spock maven,在 ubuntu 上使用 surefire 版本 2.22.0。直到 2 周前它工作正常,但突然间我犯了错误ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?。下面是我的配置:

Maven Version: Apache Maven 3.6.0 
Java version: openjdk version "1.8.0_181"
M3_HOME : /opt/maven
Run Code Online (Sandbox Code Playgroud)

当我点击mvn -Dtest="some test " test 命令时,它会引发以下错误:

ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /home/web/workspace/Durgesh_Delete1 && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /home/web/workspace/Durgesh_Delete1/target/surefire/surefirebooter1782527278200611298.jar /home/web/workspace/Durgesh_Delete1/target/surefire 2018-11-16T11-10-54_226-jvmRun3 surefire2754275980317815656tmp surefire_01299389042676135686tmp
Error occurred in starting fork, check …
Run Code Online (Sandbox Code Playgroud)

maven-3 maven

5
推荐指数
1
解决办法
1万
查看次数

杀死 self fork JVM。PING 超时已过

编辑:我只是想澄清一下,为了提出一个有已知、客观答案的问题,这个问题是,“Killing self fork JVM。PING timeout elapsed”实际上意味着什么,例如 ping 是什么,以及为什么failsafe决定它应该退出测试过程?由于这是 StackOverflow,因此请不要回复修复某些虚拟机退出的建议,尤其是那些导致与我们下面看到的行为不同的建议。例如,控制台中没有 OutOfMemoryError,因此我认为虚拟机没有耗尽堆空间。如果您确实这样回答,SO 管理员可能会误解我的问题并锁定或关闭它。

我们有时会在 CI 构建中遇到虚拟机崩溃的情况,例如:

[INFO] Results:
[INFO] 
[WARNING] Tests run: 8152, Failures: 0, Errors: 0, Skipped: 31
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.22.1:verify (integration-test) on project app_server: There are test failures.
[ERROR] 
[ERROR] Please refer to /builds/App/Development/App/app_server/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit …
Run Code Online (Sandbox Code Playgroud)

maven maven-surefire-plugin maven-failsafe-plugin

5
推荐指数
1
解决办法
5770
查看次数