Maven surefire插件使java 11上的jvm崩溃(直接写入派生JVM 1中的本机流导致STDOUT损坏)

bihw5rsg  于 2022-11-07  发布在  Maven
关注(0)|答案(5)|浏览(423)

使用java 11运行maven构建时,该构建会在运行测试时发出以下警告:

[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file /home/thomas/code/irdeto-control/fps-license-service/fps/target/surefire-reports/2019-04-11T14-05-32_318-jvmRun1.dumpstream

...生成失败后,后跟以下stderr输出:

$ cat error.message 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project fps: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/user/code/employer-control/fps-license-service/fps/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] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/user/code/employer-control/fps-license-service/fps && /usr/lib/jvm/jdk-11.0.2/bin/java '-javaagent:/home/user/.m2/repository/org/jacoco/org.jacoco.agent/0.8.0/org.jacoco.agent-0.8.0-runtime.jar=destfile=/home/user/code/employer-control/fps-license-service/fps/target/jacoco.exec,excludes=com.employer.rights.fairplay.*' -jar /home/user/code/employer-control/fps-license-service/fps/target/surefire/surefirebooter7853689441541829546.jar /home/user/code/employer-control/fps-license-service/fps/target/surefire 2019-04-11T14-05-32_318-jvmRun1 surefire11275213325677189658tmp surefire_01035200394006888746tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 134
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/user/code/employer-control/fps-license-service/fps && /usr/lib/jvm/jdk-11.0.2/bin/java '-javaagent:/home/user/.m2/repository/org/jacoco/org.jacoco.agent/0.8.0/org.jacoco.agent-0.8.0-runtime.jar=destfile=/home/user/code/employer-control/fps-license-service/fps/target/jacoco.exec,excludes=com.employer.rights.fairplay.*' -jar /home/user/code/employer-control/fps-license-service/fps/target/surefire/surefirebooter7853689441541829546.jar /home/user/code/employer-control/fps-license-service/fps/target/surefire 2019-04-11T14-05-32_318-jvmRun1 surefire11275213325677189658tmp surefire_01035200394006888746tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 134
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[ERROR]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

//忽略堆栈框架
下面是从转储流中提取的有关上述错误的内容:


# Created at 2019-04-11T14:05:32.824

Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'FATAL ERROR in native method: processing of -javaagent failed'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'FATAL ERROR in native method: processing of -javaagent failed'.
        at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
        at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
        at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
        at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
        at java.base/java.lang.Thread.run(Thread.java:834)

将surefire版本降到2.18会阻止jvm崩溃,但不会执行测试。任何高于2.18的surefire版本(包括最新版本)都会因上面的错误而崩溃。
我显然不是唯一一个遇到这个问题的人,因为它也显示为here
此外,surefire开发社区也知道这个问题,因为它被讨论了here
也就是说,不像大多数问题,往往是解决在更近版本的插件,这个问题似乎提出了它的丑陋的头再次与更近版本的surefire和jvm。
欢迎您提供任何解决方案或解决方法。我使用的是以下版本:
我的意思是说,如果你有一个好的选择,你可以选择一个好的选择。2018年2月24日20:49:05+01:00)

Java版本:11.0.2,厂商:甲骨文公司

操作系统名称:“linux”,版本:“4.15.0-47-通用”,拱形:“amd 64”,系列:“UNIX”

maven.编译器.源代码:1.8
Maven.编译器.目标:1.8
maven-surefire插件版本:2.18〈使用的版本〈= 3.0.0-M3

n1bvdmb6

n1bvdmb61#

设置 forkCount=0 本质上是个坏主意。我们决定在转储文件中报告这些问题,以迫使您搜索破坏标准输出的库。这里Maven用户提到了一个框架,和Arquillian中也发现了同样的问题,这些问题已经被解决很长时间了。因此,Surefire决定使用另一个通道,这是一个新的TCP/IP。在版本3.0.0-M5中,默认情况下不会启用此通道。您必须在未来的版本3.0.0-M5中自行启用此预览功能,如下所示:

<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>

这将是一个相当大的变化,这将最终在版本3.0.0中启用。

cl25kdpy

cl25kdpy2#

不是修复,而是解决方法,不要同时、异步运行测试:

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>${maven-surefire-plugin.version}</version>
      <configuration>
        <forkCount>0</forkCount>
      </configuration>
    </plugin>
ecfdbz9o

ecfdbz9o3#

在pom.xml中添加这些插件

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
</plugin>
<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
</plugin>
jum4pzuy

jum4pzuy4#

我遇到了同样的问题**java版本“1.8.0_211”该进程启动新的java.exe控制台,并显示以下消息失败
“[错误]分叉的VM在没有正确说再见的情况下终止。VM崩溃还是调用了System.exit?[错误]命令是cmd. exe/X /C““C:\Program Files\Java\jdk1.8.0_211\jre\bin\java”
我已经解决了用
java版本“1.8.0_202”**编译的问题,但我还不明白这两个java版本之间有什么区别。

nqwrtyyt

nqwrtyyt5#

如果找不到模块,也会发生这种情况。
在我的情况下我已经看到:
由于直接写入派生JVM 1中的本机流而导致STDOUT损坏。流'java.lang.module。FindException:未找到模块jcardsim“。
这似乎与问题描述完全无关,但一个未找到的模块显然会导致maven-surefire-plugin:3.0.0-M5出现这种情况。

相关问题