Java Maven build和Maven failsafe插件-分叉的VM在没有适当告别的情况下终止

Java Maven build和Maven failsafe插件-分叉的VM在没有适当告别的情况下终止,java,maven,docker,windows-10,maven-surefire-plugin,Java,Maven,Docker,Windows 10,Maven Surefire Plugin,我使用Docker和进行集成测试 在我的Windows 10(更新到Windows 10 1709)机器上,我的Maven 3.5.0build遇到以下错误: [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 refe

我使用Docker和进行集成测试

在我的Windows 10(更新到Windows 10 1709)机器上,我的
Maven 3.5.0
build遇到以下错误:

[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 occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] com.example.domain.api.flag.FlagControllerIT
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR]         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
[ERROR]         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
[ERROR]         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
[ERROR]         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
现在我不知道会出什么问题,我没有看到我的测试有任何失败

这个问题的原因是什么?如何解决

已更新

我的项目具有以下配置:

父级
pom.xml

<build>
 <plugins>
  <plugin>
   <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
     <argLine>-Dfile.encoding=UTF-8 -Xms1024m -Xmx1024m -XX:PermSize=1024m -noverify</argLine>
    </configuration>
   </plugin>
  </plugins>
 </build>
<profiles>
 <profile>
  <id>local</id>
  <build>
   <plugins>
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <configuration>                            
      <skipTests>true</skipTests>
     </configuration>
    </plugin>
   </plugins>
  </build>
 </profile>
</profiles>
如你所见,我补充道

<argLine>-Dfile.encoding=UTF-8 -Xms1024m -Xmx1G -XX:PermSize=1024m -noverify</argLine>
这是完整详细的输出日志:

Windows 10 1709更新


现在我认为这个问题可能与Windows101709更新有关。。。我使用docker和进行集成测试,发现以下主题-此更新和虚拟化肯定有问题…

使用Manven OPT参数进行尝试


export-MAVEN\u OPTS=“-Xms1024m-Xmx1G-XX:PermSize=1024m-noverify”

我也有类似的错误,与surefire插件上的forkstarter相关 也许您可以尝试在
pom.xml

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>--add-modules java.base ${argLine} -Xmx1024m -XX:MaxPermSize=256m</argLine>
                <forkCount>3</forkCount>
                <reuseForks>true</reuseForks>
            </configuration>
        </plugin>

org.apache.maven.plugins
maven surefire插件
--添加模块java.base${argLine}-Xmx1024m-XX:MaxPermSize=256m
3.
真的

希望,这可以帮助您

我也有同样的问题,并找到了三个适合我的解决方案:

<plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
                    <includes>
                        <include>**/Test*.java</include>
                        <include>**/*Test.java</include>
                    </includes>
                    <properties>
                        <excludeTags>slow</excludeTags>
                    </properties>
                </configuration>
            </plugin>
问题描述 问题在于maven pluginmaven surefire plugin仅在版本2.20.1和2.21.0中存在。我检查过了,您使用的是2.20.1版

解决方案1 将插件版本升级到2.22.0。外接程序pom.xml

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.22.0</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.20</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <testFailureIgnore>true</testFailureIgnore>
  </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.22.0
解决方案2 将插件版本降级为2.20。外接程序pom.xml

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.22.0</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.20</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <testFailureIgnore>true</testFailureIgnore>
  </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
2.20
解决方案3 使用插件配置testFailureIgnore。外接程序pom.xml

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.22.0</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.20</version>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <testFailureIgnore>true</testFailureIgnore>
  </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
真的

由于多种原因,虚拟机可能会崩溃。我在此强调另一个原因,因为它可能会崩溃

我使用maven surefire插件版本2.22.0和jvm配置-Xmx2048m,但仍然失败

故障原因: 我无意中将windows命令提示符“窗口缓冲区大小”的宽度更改为2000,而不是更改高度。在我的例子中,它导致vm崩溃。当我使用GitBash运行构建时,它运行得很好。因此,我能够找出问题所在,并将命令提示符“window buffer size”宽度恢复为默认值,对我来说效果很好

故障排除步骤:

  • 使用不同的命令工具验证此问题。与窗口命令提示符一样,gitbash

我使用maven surefire插件:2.22.1,但分叉VM仍然崩溃。 在我的例子中,maven surefire插件的配置ForkedProcessExitTimeOutines很有帮助。默认值是因为maven surefire插件:2.20.1 30秒。我的项目需要进行非常耗时的测试,因此分叉的JVM将失效。使用以下属性在pom中配置插件可以解决此问题

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
                <forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
        </configuration>
</plugin>

org.apache.maven.plugins
maven surefire插件
120

我的版本是2.22.2,但仍然会出现该错误。我通过设置surefire的超时来通过此操作。因此,最新添加的测试增加了执行时间,超过了默认的30秒

mvn test -Dsurefire.exitTimeout=40
超时的默认值为30

2.22.2


编辑:实际上,测试期间发生的日志记录占用了太多的时间,导致超时。因此,我更改了日志记录级别。

我有同样的问题,以下解决方案对我有效:

<plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
                    <includes>
                        <include>**/Test*.java</include>
                        <include>**/*Test.java</include>
                    </includes>
                    <properties>
                        <excludeTags>slow</excludeTags>
                    </properties>
                </configuration>
            </plugin>

maven surefire插件
2.22.1
120
**/Test*.java
**/*Test.java
缓慢的

谢谢您的回答,请查看我的最新问题。不幸的是,它仍然不起作用。我还添加了完整详细的输出日志。它得到解决了吗?我也看到了同样的问题,我不知道怎么做——但它现在对我来说运行得很好,我收到了这个错误,但在后台,进程使用端口5005运行,就像我在eclipse中运行它一样。当我在控制台中终止进程时,它开始工作。我尝试了这个,它一直在工作。很难说清楚,因为问题是间歇性的。使用testcontainers和解决方案1更新Windows 10 1709也有同样的问题:将surefire&failsafe插件升级到2.22.0适用于usSolution 3
true
将忽略测试用例,那么这一个有什么用?如果我没有错误的话,这也是ignore assert语句,使用该属性
120
解决了与我相同的问题。这也解决了我的问题。我认为,越来越多的测试类导致了这个问题。上次我的测试再次崩溃,属性120也崩溃了。但是我在下面的链接中找到了新的属性来修复崩溃。这个解决方案为我解决了问题。理想情况下,你应该解释为什么这个解决方案有效——而不仅仅是提供答案。