Maven Surefire plugin "Error occured in starting fork, check output in log"
Asked Answered
G

4

48

I get the following error

BUILD ERROR
Error occured in starting fork, check output in log

when using Maven 2.2.1 and Surefire plugin 2.11 while running junit test cases.

How can I fix it?

Griseous answered 16/2, 2012 at 23:18 Comment(6)
Launch your build with debug logs : add -X to your command line.Centum
This may also be due to the issue SUREFIRE-870, which is fixed in the 2.12.1 version of the plugin.Rudimentary
Actual problem for recent versions (2.20.1)Byng
Possible duplicate question: Strategy for debugging surefire “The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?”Anthiathia
had issues - upgraded surefire plugin to 2.22.2, worked ok.Alexisaley
For reference, I had this issue when using an old version of jacoco with java 11, and having --illegal-access=permit defined as a argline to surefire. Upgrading to jacoco 0.8.5 and removing the argline configuration fixed my issue.Goss
G
34

You need to setup surefire plugin to use <forkMode>once</forkMode> like this:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
            <configuration>
                <skipTests>false</skipTests>
                <testFailureIgnore>true</testFailureIgnore>
                <forkMode>once</forkMode>
            </configuration>
</plugin>
Griseous answered 17/2, 2012 at 19:33 Comment(4)
the option is deprecated, any updated combination to solve the issue?Signboard
I fixed it with <forkCount>0</forkCount> (instead of the deprecated forkMode).Binky
notice that forkMode once is NOT the same as forkCount 0.From maven.apache.org/surefire/maven-surefire-plugin/examples/…, the equivalent would be forkCount 1 with reuseForks true. However, seems forkCount 0 fixes the issue.Gena
with this you loose jacoco coverage on sonar...any other ideas because i m in the same situation. thanksDibs
H
4

I was facing the same issue on my local with maven-surefire-plugin plugin.

After adding <forkCount>0</forkCount> to maven-surefire-plugin plugin it worked for me.

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-Xmx1024m -XX:MaxPermSize=256m ${surefireArgLine}</argLine>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
                <forkCount>0</forkCount>
            </configuration>
        </plugin>
Hue answered 5/5, 2022 at 10:58 Comment(0)
P
0

For me worked as @Ganesh Thorat.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.2.5</version>
  <configuration>
      <forkCount>0</forkCount>
  </configuration>
</plugin>
Pneumato answered 20/3 at 13:52 Comment(0)
T
-1

encountered the same issue

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.1</version>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>  

set "useSystemClassLoader as false"

Tomfoolery answered 28/3, 2021 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.