Spring Boot构建失败:启动fork时出错,退出代码134

时间:2018-11-15 12:24:24

标签: java maven spring-boot maven-surefire-plugin

将我们的微服务pom升级为使用Spring Boot 2.1.0 RELEASE(从2.0.5 RELEASE开始)后,我们开始偶尔遇到构建失败的情况。有人看到了这个并且有解决方案(请参见下面的错误)吗?

Maven命令:mvn全新安装

在测试执行过程中生成的带有以下注释的测试失败:

@RunWith(SpringRunner.class)
@SpringBootTest

Java

java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

我们pom中的片段似乎是导致此问题的原因。

来自pom的Surefire插件

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- Below 955m we get failures "VM crash or System.exit called?". Set with safety margin. -->
                    <argLine>@{argLine} -Xmx2048m</argLine>
                    <includes>
                        <include>**/*Tests.java</include>
                        <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/*IT.java</exclude>
                        <exclude>**/*ManualTest.java</exclude>
                    </excludes>
                    <skipTests>false</skipTests>
                </configuration>
            </plugin>

我们还使用Jacoco

<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.2</version>
                <configuration>
                    <excludes>
                        <exclude>**/is/applicon/wsapi/*/*.*</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

Maven构建错误

    [ERROR] Please refer to /XXXXX/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 /XXXXX && /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java '-javaagent:/Users/xxxx/.m2/repository/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar=destfile=/XXXXX/target/jacoco.exec,excludes=**/is/applicon/wsapi/*/*.*' -Xmx2048m -jar /XXXXX/target/surefire/surefirebooter620918509052727724.jar /XXXXX/target/surefire 2018-11-15T13-00-33_562-jvmRun1 surefire14123679476795131809tmp surefire_011360897091263090402tmp
[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 /Users/XXXXX && /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java '-javaagent:/Users/xxx/.m2/repository/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar=destfile=/XXXXX/target/jacoco.exec,excludes=**/is/applicon/wsapi/*/*.*' -Xmx2048m -jar /XXXXX/target/surefire/surefirebooter620918509052727724.jar /XXXXX/target/surefire 2018-11-15T13-00-33_562-jvmRun1 surefire14123679476795131809tmp surefire_011360897091263090402tmp
[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)
[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:56)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954)
[ERROR]     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR]     at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]     at java.base/java.lang.reflect.Method.invoke(Method.java:564)
[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)

转储文件中的片段:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000117800245, pid=14403, tid=8963
#
# JRE version: Java(TM) SE Runtime Environment (10.0.2+13) (build 10.0.2+13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.2+13, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# J 14066 c2 org.springframework.boot.context.properties.source.ConfigurationPropertyName.elementEquals(Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName$Elements;Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName$Elements;I)Z (426 bytes) @ 0x0000000117800245 [0x00000001178001e0+0x0000000000000065]
#


---------------  S U M M A R Y ------------

Command Line: -javaagent:/Users/xxx/.m2/repository/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar=destfile=/XXXXX/target/jacoco.exec,excludes=**/is/applicon/wsapi/*/*.* -Xmx2048m /XXXXX/target/surefire/surefirebooter620918509052727724.jar /XXXXX/target/surefire 2018-11-15T13-00-33_562-jvmRun1 surefire14123679476795131809tmp surefire_011360897091263090402tmp

Host: MacBookPro14,3 x86_64 2900 MHz, 8 cores, 16G, Darwin 17.7.0
Time: Thu Nov 15 13:00:53 2018 CET elapsed time: 19 seconds (0d 0h 0m 19s)

---------------  T H R E A D  ---------------

Current thread (0x00007feac3801800):  JavaThread "main" [_thread_in_Java, id=8963, stack(0x00000001021a0000,0x00000001022a0000)]

Stack: [0x00000001021a0000,0x00000001022a0000],  sp=0x000000010229e0a0,  free space=1016k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
J 14066 c2 org.springframework.boot.context.properties.source.ConfigurationPropertyName.elementEquals(Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName$Elements;Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName$Elements;I)Z (426 bytes) @ 0x0000000117800245 [0x00000001178001e0+0x0000000000000065]
J 6720 c2 org.springframework.boot.context.properties.source.ConfigurationPropertyName.equals(Ljava/lang/Object;)Z (215 bytes) @ 0x0000000117a60af8 [0x0000000117a60720+0x00000000000003d8]
J 14007 c2 org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.find([Lorg/springframework/boot/context/properties/source/PropertyMapping;Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName;)Lorg/springframework/boot/context/properties/source/ConfigurationProperty; (108 bytes) @ 0x0000000117fb1a10 [0x0000000117fb1900+0x0000000000000110]
J 3641 c1 org.springframework.boot.context.properties.source.SpringIterableConfigurationPropertySource.getConfigurationProperty(Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName;)Lorg/springframework/boot/context/properties/source/ConfigurationProperty; (53 bytes) @ 0x00000001107e43d4 [0x00000001107e4240+0x0000000000000194]
j  org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(Lorg/springframework/boot/context/properties/source/ConfigurationPropertyName;)Lorg/springframework/boot/context/properties/source/ConfigurationProperty;+61
j  org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(Ljava/lang/String;)Lorg/springframework/boot/context/properties/source/ConfigurationProperty;+10
j  org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.getProperty(Ljava/lang/String;)Ljava/lang/Object;+6
j  org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(Ljava/lang/String;Ljava/lang/Class;Z)Ljava/lang/Object;+175
j  org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;+8
j  org.springframework.core.env.AbstractPropertyResolver.getProperty(Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;+8
j  org.springframework.core.env.AbstractEnvironment.getProperty(Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;+12
j  org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration$SameManagementContextConfiguration.verifySslConfiguration()V+20
j  org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration$SameManagementContextConfiguration.afterSingletonsInstantiated()V+5
j  org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons()V+614
j  org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(Lorg/springframework/beans/factory/config/ConfigurableListableBeanFactory;)V+224
j  org.springframework.context.support.AbstractApplicationContext.refresh()V+113
j  org.springframework.boot.SpringApplication.refresh(Lorg/springframework/context/ApplicationContext;)V+20
j  org.springframework.boot.SpringApplication.refreshContext(Lorg/springframework/context/ConfigurableApplicationContext;)V+6
j  org.springframework.boot.SpringApplication.run([Ljava/lang/String;)Lorg/springframework/context/ConfigurableApplicationContext;+193
j  org.springframework.boot.test.context.SpringBootContextLoader.loadContext(Lorg/springframework/test/context/MergedContextConfiguration;)Lorg/springframework/context/ApplicationContext;+482
j  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(Lorg/springframework/test/context/MergedContextConfiguration;)Lorg/springframework/context/ApplicationContext;+39
j  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(Lorg/springframework/test/context/MergedContextConfiguration;)Lorg/springframework/context/ApplicationContext;+40
j  org.springframework.test.context.support.DefaultTestContext.getApplicationContext()Lorg/springframework/context/ApplicationContext;+12
j  org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(Lorg/springframework/test/context/TestContext;)V+40
j  org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(Lorg/springframework/test/context/TestContext;)V+6
j  org.springframework.test.context.TestContextManager.prepareTestInstance(Ljava/lang/Object;)V+128
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest()Ljava/lang/Object;+19
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall()Ljava/lang/Object;+8
j  org.junit.internal.runners.model.ReflectiveCallable.run()Ljava/lang/Object;+5
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(Lorg/junit/runners/model/FrameworkMethod;)Lorg/junit/runners/model/Statement;+17
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(Lorg/junit/runners/model/FrameworkMethod;Lorg/junit/runner/notification/RunNotifier;)V+53
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(Ljava/lang/Object;Lorg/junit/runner/notification/RunNotifier;)V+10
j  org.junit.runners.ParentRunner$3.run()V+16
j  org.junit.runners.ParentRunner$1.schedule(Ljava/lang/Runnable;)V+5
j  org.junit.runners.ParentRunner.runChildren(Lorg/junit/runner/notification/RunNotifier;)V+66
j  org.junit.runners.ParentRunner.access$000(Lorg/junit/runners/ParentRunner;Lorg/junit/runner/notification/RunNotifier;)V+6
j  org.junit.runners.ParentRunner$2.evaluate()V+12
j  org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate()V+19
j  org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate()V+20
j  org.junit.runners.ParentRunner.run(Lorg/junit/runner/notification/RunNotifier;)V+36
j  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(Lorg/junit/runner/notification/RunNotifier;)V+38
j  org.apache.maven.surefire.junit4.JUnit4Provider.execute(Ljava/lang/Class;Lorg/apache/maven/surefire/common/junit4/Notifier;Lorg/junit/runner/manipulation/Filter;)V+137
j  org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(Ljava/lang/Class;Lorg/apache/maven/surefire/common/junit4/Notifier;)V+122
j  org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(Ljava/lang/Class;Lorg/apache/maven/surefire/report/RunListener;Lorg/apache/maven/surefire/common/junit4/Notifier;)V+51
j  org.apache.maven.surefire.junit4.JUnit4Provider.invoke(Ljava/lang/Object;)Lorg/apache/maven/surefire/suite/RunResult;+340
j  org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(Lorg/apache/maven/surefire/booter/ForkingReporterFactory;)Lorg/apache/maven/surefire/suite/RunResult;+18
j  org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess()Lorg/apache/maven/surefire/suite/RunResult;+16
j  org.apache.maven.surefire.booter.ForkedBooter.execute()V+5
j  org.apache.maven.surefire.booter.ForkedBooter.main([Ljava/lang/String;)V+59
v  ~StubRoutines::call_stub
V  [libjvm.dylib+0x3d8c0e]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x216
V  [libjvm.dylib+0x41856d]  jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x12d
V  [libjvm.dylib+0x41ae0d]  jni_CallStaticVoidMethod+0x183
C  [java+0x5034]  JavaMain+0xb9f
C  [libsystem_pthread.dylib+0x3661]  _pthread_body+0x154
C  [libsystem_pthread.dylib+0x350d]  _pthread_body+0x0
C  [libsystem_pthread.dylib+0x2bf9]  thread_start+0xd
C  0x0000000000000000

1 个答案:

答案 0 :(得分:1)

实际上,错误情况看起来像是有关无法在jwm中派生进程的。

启动分叉时发生错误,请在日志[ERROR]中检查输出 退出代码:134

thek标记删除jacoco-maven-plugin的另一种方法,如果分叉计数与您的情况无关,则可以覆盖forkCount的{​​{1}}。

maven-surefire-plugin

您还可以查看有关forking parallel test processes的详细信息。