Maven error occurred in starting fork, check output in log
Asked Answered
P

7

13

I use Maven, docker-maven-plugin and Spring Boot. Right now I run into the following issue:

[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 /C "c:\Java\jdk1.8.0_162\jre\bin\java -jar C:\Users\ALEXAN~1\AppData\Local\Temp\surefire7684467242957210997\surefirebooter6934205730694228299.jar C:\Users\Alexander\AppData\Local\Temp\surefire7684467242957210997 2018-03-30T20-28-03_824-jvmRun1 surefire8708053899862809316tmp surefire_06397887630134904290tmp"
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] com.decisionwanted.domain.DecisionCharacteristicIT
[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)
[ERROR] -> [Help 1]

I read that this issue can be potentially related to maven-surefire-plugin so I have added to my parent pom:

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <forkCount>0</forkCount>
            </configuration>
        </plugin>
    <plugins>
</pluginManagement>

and to inherited poms:

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

but it doesn't help.

How to fix this issue ?

Prodigal answered 30/3, 2018 at 17:37 Comment(11)
Try to downgrade to 2.19.1 instead ..?Dongola
Check https://mcmap.net/q/98632/-the-forked-vm-terminated-without-saying-properly-goodbye-vm-crash-or-system-exit-called/3530898 and https://mcmap.net/q/100834/-maven-build-and-maven-failsafe-plugin-the-forked-vm-terminated-without-properly-saying-goodbye/3530898Dichotomous
I was unable to find the solution that fixes the issue thereProdigal
@Dongola everything was working fine before my windows 10 restart this nightProdigal
Please set the version to 2.19.1...Dongola
@Dongola ok, in progress. Do I need to use <forkCount>0</forkCount> with 2.19.1 ?Prodigal
No you shouldn't need it...Dongola
Unable to complete the build.. something wrong with my Docker. Build is unable to properly start MongoDB - NETWORK [initandlisten] waiting for connections on port 27017Prodigal
I tried 2.19.1 - it doesn't help. Some recent update destroyed the build systemProdigal
@Dongola thanks for your suggestion! I have set the maven-failsafe-plugin and maven-surefire-plugin versions to 2.18.1 and looks like the issue is goneProdigal
Upgrading from 3.0.0-M5 to 3.0.0-M8 worked for me.Unreserved
T
8

I also faced this in my local environment (build was working fine on other environments). So I did not revise pom.xml, instead, I added forkCount=0 as command line argument and it solved the problem. Like:

mvn clean install -DforkCount=0
Toboggan answered 11/2, 2021 at 12:10 Comment(1)
I too faced the same issue and based on this answer I added the below to the pom' <properties> and that fixed the issue <forkCount>0</forkCount>Catamount
S
5

I was facing the same issue, adding below worked for me: version 3.0.0-M3 fixes the problem

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <forkCount>0</forkCount>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>
Sybil answered 9/8, 2019 at 7:35 Comment(0)
B
5

I was also facing the same issue.

[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: Error occurred in starting fork, check output in log

In my context, I was building a spring boot application. All tests were ok, BUT, the application did not close properly due to an issue in the app code shutdown process. I guess that the process was not returning an exit code equals to 0.

Once we fixed this shutdown issue, this surefire plugin exception did not occured anymore.

It may be an hint to your problem.

Benares answered 30/10, 2019 at 19:54 Comment(0)
T
2

I had a similar error because I had a dash - in my branch name, and Jenkins failed.

[ERROR] Error occurred in starting fork, check output in log 
[ERROR] Process Exit Code: 1 
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called? ... 
[ERROR] Error occurred in starting fork, check output in log [ERROR] Process Exit Code: 1 
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:671) 
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533) 
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278) 
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244) 
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149) 
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978) 
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)

After making an identical branch with another name I worked again.

Testosterone answered 6/11, 2019 at 14:43 Comment(2)
How did you figure out the problem was the -?Legaspi
because it was working with branches whose name contained underscores instead of dashesTestosterone
A
0

Set useSystemClassloader to false:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>
Anthracosilicosis answered 6/3, 2019 at 7:28 Comment(2)
Can you provide any explanation as to why this would solve the problem? I'm cautious to use it without knowing what it does.Abroad
There's always the documentation: maven.apache.org/surefire/maven-surefire-plugin/examples/… That link explains how OS limitations cause these problems, the trade-offs involved in the possible approaches and a potential solution.Franciscofranciska
M
0

In addition to aure_bobo answer who say that legacy code could cause exit code != 0 :

In my case, I had my IT stage all success and got this error on CI/CD only: I were unable to diagnose/reproduce locally: so unable to know why and wich module goes wrong on surefire fork shutdown: no stack trace from surefire 3.0.0-M5 code because it was not a timeout.

So I used this tip:

  • to troubleshoot application failure, temporarly configure failsafe plugin to never fork (doc: forkMode>never):

          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-failsafe-plugin</artifactId>
              <version>${maven-failsafe-plugin.version}</version>
              <configuration>
                  <!-- (...) -->
                  <forkMode>never</forkMode>
                  <!-- (...) -->
              </configuration>
    

In my case, with this tip I were able to reproduce: all IT in success, then got the full stack trace at shutdown time.

Meiny answered 1/9, 2020 at 10:7 Comment(0)
T
-1

I was trying to execute my application in a folder that contained '&'.

After removing the special characters it got executed with no problems.

Timekeeper answered 20/12, 2023 at 12:19 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Brittaneybrittani

© 2022 - 2024 — McMap. All rights reserved.