Maven Surefire: Error occured in starting fork
Asked Answered
A

4

8

When I am trying to run

mvn test

I always get the Error Message that maven-surefire error ocurred in starring fork. It has something to do with my local settings, on my colleagues PC it's working fine. I hope that somebody has an idea what is wrong with my pc :)

A part of the Error Message:

  1. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project exercise00-assignment01: Error occurred in starting fork, check output in log -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project exercise00-assignment01: Error occurred in starting fork, check output in log

  2. Caused by:
        org.apache.maven.surefire.booter.SurefireBooterForkException: Error
        occurred in starting fork, check output in log
            at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork
        (ForkStarter.java:284)
    

I am using win10, jdk: 1.8.0_202, maven: 3.6.0

My pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>at.tuwien.swtesting</groupId>
    <artifactId>exercise00-assignment01</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging> 

    <name>01-RingBufferTest</name>
    <description>Entry exercise.</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>  
        <dependency>  
            <groupId>junit</groupId>  
            <artifactId>junit</artifactId>  
            <version>4.12</version>  
            <scope>test</scope>  
        </dependency>  
    </dependencies>

</project>
Arapaho answered 29/3, 2019 at 17:31 Comment(5)
First please upgrade to at least 2.22.1 of maven-surefire-plugin....Almedaalmeeta
Where do I need to Update this Version? I can't modify the pom.xmlArapaho
You can't modify the pom? does not make sense...Almedaalmeeta
The pom.xml is from my course lecture, normally it should also work with this settings. On my colleagues PC it is working with this file.Arapaho
Please show the full error output...Almedaalmeeta
A
1

So I added the following Code to my pom.xml

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

The Error Message changed:

[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. [ERROR] Error occurred in starting fork, check output in log [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: Error occurred in starting fork, check output in log [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:623) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)

Edit

I finally found my problem, in my path to the folder there was an '&' and windows couldn't handle it. This was the reason for the different Error Messages

Arapaho answered 29/3, 2019 at 18:6 Comment(2)
Do you mean "&" is in the cmd.exe string? Mine is "cmd.exe /X /C "C:\Users\someone\tools\jdk-8u211\jre\bin\java -javaagent:C:\\Users\\someone\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.7.201606060606\\org.jacoco.agent-0.7.7.201606060606-runtime.jar=destfile=C:\\Users\\someone\\abc_repo\\bbb_repo\\services-parent\\payment-services-settlement-impl\\..\\target\\jacoco.exec,append=true -noverify -Duser.timezone=US/Central -Duser.language=en org.apache.maven.surefire.booter.ForkedBooter C:\Users\someone\AppData\Local\Temp\surefire5536645681570537156 ..."Reaction
It is very long. Don't know how to make it short.Reaction
L
9

I recently stuck in the same issue. After a lot of research, I got below the resolution

ForkCount should be set as "0"

Update your pom file as:-

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
        <forkCount>0</forkCount>
        <suiteXmlFiles>`enter code here`
        <suiteXmlFile>testng.xml</suiteXmlFile>
        </suiteXmlFiles>
        </configuration>
    </plugin>
</plugins>

Landseer answered 2/6, 2019 at 10:4 Comment(2)
I tried on 3.0.0-M3 version too and build is created successfullyLandseer
I think this appears to work because it is skipping tests. Be very careful about using it! Maven also warns about it nowRegazzi
A
1

So I added the following Code to my pom.xml

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M3</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

The Error Message changed:

[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream. [ERROR] Error occurred in starting fork, check output in log [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: Error occurred in starting fork, check output in log [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:623) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283) [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)

Edit

I finally found my problem, in my path to the folder there was an '&' and windows couldn't handle it. This was the reason for the different Error Messages

Arapaho answered 29/3, 2019 at 18:6 Comment(2)
Do you mean "&" is in the cmd.exe string? Mine is "cmd.exe /X /C "C:\Users\someone\tools\jdk-8u211\jre\bin\java -javaagent:C:\\Users\\someone\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.7.201606060606\\org.jacoco.agent-0.7.7.201606060606-runtime.jar=destfile=C:\\Users\\someone\\abc_repo\\bbb_repo\\services-parent\\payment-services-settlement-impl\\..\\target\\jacoco.exec,append=true -noverify -Duser.timezone=US/Central -Duser.language=en org.apache.maven.surefire.booter.ForkedBooter C:\Users\someone\AppData\Local\Temp\surefire5536645681570537156 ..."Reaction
It is very long. Don't know how to make it short.Reaction
L
0

Another solution that worked for me after trying numerous other suggestions was having a fork for every test class. Setting fork to 0 worked intermittently which I expected to work as when run with debug=true, they passed each time (no fork in debug). 3.0.0-M4

surefire forkcount documentation

<plugins>
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <configuration>
         <forkCount>number of test classes</forkCount>
       </configuration>
    </plugin>
</plugins>
Lithopone answered 28/5, 2020 at 9:0 Comment(0)
R
-1

I was getting this on my MacBook and it was fixed by restarting the computer. Not a very satisfying fix but it worked.

Regazzi answered 1/1, 2023 at 20:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.