0

Maven command build "mvn clean install" fails to run maven-surefire-plugin tests and generates error SurefireBooterForkException.

Background

Found that there was a bug in maven-surefire-plugin as reported here: stackoverflow.com/Spring Boot fails to run maven-surefire-plugin in the old version, and this was fixed in 3.0.0-M1 as mentioned on the ticket Surefire manifest jar classloading broken

Current Issue The same issue of maven-surefire-plugin still exists in the latest versions "3.0.0-M4"/"3.0.0-M5":

  • When using surefire plugin version "3.0.0-M5"

    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [ERROR] Picked up JAVA_TOOL_OPTIONS: -Dsun.locale.formatasdefault=true
    [INFO]
    [INFO] Results:
    [INFO]
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

  • When using surefire plugin version "3.0.0-M4"

    [INFO]
    [INFO] Results:
    [INFO]
    [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 01:11 min
    [INFO] Finished at: 2021-10-21T12:42:28+05:30
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test) on project MyRepositoryProject: There are test failures.
    [ERROR]
    [ERROR] Please refer to E:\sts-4.11.0.RELEASE_Workspace\MyRepositoryProject \target\surefire-reports for the individual test results.
    ...
    [ERROR] Process Exit Code: 0
    [ERROR] Crashed tests:
    [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
    [ERROR] com.freschesolutions.xa.data.service.AbstractProgramDtoServiceTest
    [ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:690)
    [ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:285)
    [ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:248)
    [ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1217)
    [ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1063)
    [ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:889)
    [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.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)

Any help will be appreciated!!!

Notes:

  • Using the JRE "1.8.0_121" / Maven “3.8.3”
  • No issue within STS/Eclipse - 'Run As > Maven Tests'
  • <forkCount>0</forkCount> resolves the maven command build issue, but this consumes too much time in running all tests

    [INFO]
    [WARNING] Tests run: 79, Failures: 0, Errors: 0, Skipped: 4
    [INFO]
    [INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ MyRepositoryProject ---
    [INFO] Building jar: E:\sts-4.11.0.RELEASE_Workspace\MyRepositoryProject\target\MyRepositoryProject-0.0.1-SNAPSHOT.jar
    ...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 04:14 min
    [INFO] Finished at: 2021-10-21T12:52:32+05:30

Kishore_2021
  • 597
  • 11
  • 34

0 Answers0