Stephane
Stephane

Reputation: 12750

Crashed tests when building a Maven project

I run a Maven user-data project integration tests, with the mvn clean install -Denv="test" -Ddb="h2" command, and they seem to pass all just fine, except that I get some crashed tests with the message: The forked VM terminated without properly saying goodbye. VM crash or System.exit called? The same error also shows up for another project user-rest which is client of the above one. That leads me to think it may not be project related.

The full output console log shows:

[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M1:verify (default) @ user-data ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  07:38 min
[INFO] Finished at: 2020-02-08T17:52:22+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M1:verify (default) on project user-data: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/stephane/dev/java/projects/user-data/target/failsafe-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] 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 /home/stephane/dev/java/projects/user-data && /home/stephane/.sdkman/candidates/java/13.0.2.hs-adpt/bin/java -jar /home/stephane/dev/java/projects/user-data/target/surefire/surefirebooter17442042042677513972.jar /home/stephane/dev/java/projects/user-data/target/surefire 2020-02-08T17-45-27_266-jvmRun1 surefire5026424780409372472tmp surefire_012665318530559224267tmp                                                                                                   
[ERROR] Process Exit Code: 0
[ERROR] Crashed tests:
[ERROR] com.thalasoft.user.data.it.service.UserServiceTest
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670)
[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)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:991)                                                                                                                  
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:837)
[ERROR]         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR]         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[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:957)
[ERROR]         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
[ERROR]         at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
[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:567)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR]         at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

The target/failsafe-reports/com.thalasoft.user.data.it.jpa.UserRepositoryTest.txt file contains:

-------------------------------------------------------------------------------
Test set: com.thalasoft.user.data.it.jpa.UserRepositoryTest
-------------------------------------------------------------------------------
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 263.924 s - in com.thalasoft.user.data.it.jpa.UserRepositoryTest

The target/failsafe-reports/failsafe-summary.xml file contains:

<?xml version="1.0" encoding="UTF-8"?>
<failsafe-summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.o
rg/surefire/maven-surefire-plugin/xsd/failsafe-summary.xsd" result="254" timeout="false">
    <completed>0</completed>
    <errors>0</errors>
    <failures>0</failures>
    <skipped>0</skipped>
    <failureMessage>org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly s
aying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /home/stephane/dev/java/projects/user-data &amp;&amp; /home/stephane/.sdkman/candidates/java/13.0.2
.hs-adpt/bin/java -jar /home/stephane/dev/java/projects/user-data/target/surefire/surefirebooter17442042042677513972.jar /hom
e/stephane/dev/java/projects/user-data/target/surefire 2020-02-08T17-45-27_266-jvmRun1 surefire5026424780409372472tmp surefir
e_012665318530559224267tmp
Process Exit Code: 0
Crashed tests:
com.thalasoft.user.data.it.service.UserServiceTest
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670)
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
        at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:991)
        at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:837)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)

The directory contains:

11:24 $ ll target/failsafe-reports/
total 32
-rw-rw-r-- 1 stephane stephane   350 févr.  8 17:49 com.thalasoft.user.data.it.jpa.UserRepositoryTest.txt
-rw-rw-r-- 1 stephane stephane  3501 févr.  8 17:52 failsafe-summary.xml
-rw-rw-r-- 1 stephane stephane 23427 févr.  8 17:49 TEST-com.thalasoft.user.data.it.jpa.UserRepositoryTest.xml

I tried under the following JAVA versions:

12.0.2-open
11.0.6-open
13.0.2.j9-adpt
13.0.2.hs-adpt

and always get the same error.

UPDATE: The integration test that was crashing, does not crash if running only that test. The mvn clean install -Denv="test" -Ddb="h2" -Dtest=UserServiceTest command shows:

[INFO] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:3.0.0-M1:verify (default) @ user-data ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ user-data ---
[INFO] Installing /home/stephane/dev/java/projects/user-data/target/user-data-0.0.1-SNAPSHOT.jar to /home/stephane/.m2/repository/com/thalasoft/user-data/0.0.1-SNAPSHOT/user-data-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/stephane/dev/java/projects/user-data/pom.xml to /home/stephane/.m2/repository/com/thalasoft/user-data/0.0.1-SNAPSHOT/user-data-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  08:32 min
[INFO] Finished at: 2020-02-09T11:41:02+01:00
[INFO] ------------------------------------------------------------------------

UPDATE: The same issue remains in the dependent user-rest project, that contains a dependency on the fixed user-data project. I tried adding the same plugin but it did not help. It had a dumpstream file which contains: Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter

✔ ~/dev/java/projects/user-rest [master|✚ 1] 
12:00 $ lsb_release -rd
Description:    Ubuntu 19.10
Release:        19.10
✔ ~/dev/java/projects/user-rest [master|✚ 1] 
12:06 $ mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/stephane/.sdkman/candidates/maven/current
Java version: 13.0.2, vendor: AdoptOpenJDK, runtime: /home/stephane/.sdkman/candidates/java/13.0.2.hs-adpt
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "5.3.0-29-generic", arch: "amd64", family: "unix"

Upvotes: 0

Views: 3271

Answers (2)

Stephane
Stephane

Reputation: 12750

The solution was to use the following property:

<forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>

Indeed the tests were so long there would be a time out in the fork.

Upvotes: 2

Govinda Sakhare
Govinda Sakhare

Reputation: 5749

I was facing the same issue in one of project. I fixed it by upgrading to the latest version of the surefire plugin and by disabling the class loader as suggested in the discussion https://github.com/carlossg/docker-maven/issues/90

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

Upvotes: 0

Related Questions