Note: I am now aware of The forked VM terminated without saying properly goodbye. VM crash or System.exit called, I tried many of the solutions expressed there and none of them work or make any difference. I documented in this question what I tried and what happened. I don't believe this is a duplicate of that question, essentially, because no answer is accepted so we can't know what the cause behind the error really was and many different problems could cause this same error (not all crashes are the same).
I'm sort of reviving a project that was left in a broken state when I try to run the tests I get this error:
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
I can't go back to a known working state, because, well, I don't know when that happened and under what conditions.
This is the full output from the command:
> mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.example:projectxserver >--------------------
[INFO] Building projectxserver 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The artifact org.hibernate:hibernate-validator:jar:6.0.17.Final has been relocated to org.hibernate.validator:hibernate-validator:jar:6.0.17.Final
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # projectxserver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # projectxserver ---
[WARNING] ***********************************************************************************************************************************************************************
[WARNING] * Required filename-based automodules detected: [javax.servlet-api-4.0.1.jar, javax.inject-1.jar]. Please don't publish this project to a public artifact repository! *
[WARNING] ***********************************************************************************************************************************************************************
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) # projectxserver ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # projectxserver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # projectxserver ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM 1. See FAQ web page and the dump file C:\Users\pupeno\Documents\projectx\code\projectxserver\target\surefire-reports\2019-09-26T05-51-30_012-jvmRun1.dumpstream
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.748 s
[INFO] Finished at: 2019-09-26T05:51:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project projectxserver: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\pupeno\Documents\projectx\code\projectxserver\target\surefire-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] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C "C:\Users\pupeno\scoop\apps\oraclejdk\current\bin\java #C:\Users\pupeno\AppData\Local\Temp\surefire12697495595942050464\surefireargs12476787747337053319 C:\Users\pupeno\AppData\Local\Temp\surefire12697495595942050464 2019-09-26T05-51-30_012-jvmRun1 surefire10872047683044717734tmp surefire_013239801033816370074tmp"
[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] Command was cmd.exe /X /C "C:\Users\pupeno\scoop\apps\oraclejdk\current\bin\java #C:\Users\pupeno\AppData\Local\Temp\surefire12697495595942050464\surefireargs12476787747337053319 C:\Users\pupeno\AppData\Local\Temp\surefire12697495595942050464 2019-09-26T05-51-30_012-jvmRun1 surefire10872047683044717734tmp surefire_013239801033816370074tmp"
[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:669)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[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:956)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[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)
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Not sure what information is relevant at this point, I'm happy to add whatever is needed to this question.
I tried OpenJDK 11, 12 and OracleJDK 12 as well as maven-sure-fire-plugin 2.22.2 and 3.0.0-M3. All give the same error.
I tried mvn clean and re-built. I tried removing my whole Maven repo, the .m2 directory.
I also tried adding <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> as explained in The forked VM terminated without saying properly goodbye. VM crash or System.exit called as well as <argLine>-Xmx2048m -XX:MaxPermSize=1024m</argLine> just to make sure, but the error remained the same. I tried this only with Oracle JDK 12.
I also tried:
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=1024m</argLine>
</configuration>
just in case the other two parameters were relevant and it failed with this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project dashmanserver: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.StartupReportConfiguration -> [Help 1]
I tried adding <testFailureIgnore>true</testFailureIgnore> but I get the same error.
Have the same issue; build works on one machine but on another machine it does not work.
Maven log on failing machine mentions a "dumpstream" file, e.g. \xxx\target\surefire-reports\2020-05-12T17-21-34_124.dumpstream
Peeking into that reveals:
# Created at 2020-05-12T17:21:35.135
Ursache: java.lang.ClassNotFoundException: LastName\/m2\repository\javax\servlet\javax/servlet-api\4/0/1\javax/servlet-api-4/0/1/jar;C:\Users\FirstName
So it turns out that I have "c:\users\FirstName LastName" as user directory, e.g. a space in my username, and I would assume that since servlet-api 4.0.1 does not have a module-info.class so there's some lookup in MANIFEST.MF I believe or whatever.
The other machine where the build is running fine is with a user directory that does not have a space in its name.
Weird thing is that it happens only when running tests, and it does not seem to matter whether useModulePath is true or false for maven-surefire-plugin
Related
I'm attempting to run the sample project from How to setup akka persistence project : https://developer.lightbend.com/start/?group=akka&project=akka-samples-persistence-dc-java
When I try to run the example using the command :
mvn exec:java -Dexec.mainClass="sample.persistence.multidc.ThumbsUpApp" -Dexec.args="cassandra"
I receive the error:
[INFO] --< com.lightbend.akka.samples:akka-sample-replicated-event-sourcing-java >--
[INFO] Building Akka replicated event sourcing multi dc sample 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) # akka-sample-replicated-event-sourcing-java ---
[WARNING]
java.lang.ClassNotFoundException: sample.persistence.multidc.ThumbsUpApp
at java.net.URLClassLoader.findClass (URLClassLoader.java:471)
at java.lang.ClassLoader.loadClass (ClassLoader.java:589)
at java.lang.ClassLoader.loadClass (ClassLoader.java:522)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:246)
at java.lang.Thread.run (Thread.java:834)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.426 s
[INFO] Finished at: 2021-07-25T20:52:54+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project akka-sample-replicated-event-sourcing-java: An exception occured while executing the Java class. sample.persistence.multidc.ThumbsUpApp -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Looking at the project source:
The package sample.persistence.multidc.ThumbsUpApp does not appear to exist. How to include the missing package sample.persistence.multidc.ThumbsUpApp ? Shouldn't this project execute without adding additional src code ?
It seems you are referencing a class name that doesn't exist in the project source.
You may use the following command instead.
mvn exec:java -Dexec.mainClass="sample.persistence.res.MainApp" -Dexec.args="cassandra"
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 && /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"
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.
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>
I downloaded the current version of the JUnit 5 sample code from https://github.com/junit-team/junit5-samples/tree/r5.2.0/ and extracted the subfolder junit5-jupiter-starter-maven to a local temp folder.
Then I openend a console window and tried to run that sample with mvnw clean test, but all I got was an java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
Full maven output (of re-run without downloads):
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building junit5-vanilla-maven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # junit5-vanilla-maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\temp\junit5-jupiter-starter-maven\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # junit5-vanilla-maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # junit5-vanilla-maven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\temp\junit5-jupiter-starter-maven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) # junit5-vanilla-maven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) # junit5-vanilla-maven ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.245 s
[INFO] Finished at: 2018-06-01T16:31:25+02:00
[INFO] Final Memory: 11M/306M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project junit5-vanilla-maven: There are test failures.
[ERROR]
[ERROR] Please refer to C:\temp\junit5-jupiter-starter-maven\target\surefire-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] There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:658)
[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)
[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] 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.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
[ERROR] at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
[ERROR] at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
mvnw --version:
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00)
Maven home: C:\Users\<XXX>\.m2\wrapper\dists\apache-maven-3.5.0-bin\6ps54u5pnnbbpr6ds9rppcc7iv\apache-maven-3.5.0
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_171\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Did I do something wrong, or can you reproduce this problem?
Since the error is
[ERROR] java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
I suggest to check the junit-platform-launcher jar file. Maybe it is corrupted.
It should be the one of\.m2\repository\org\junit\platform\junit-platform-launcher\1.2.0\junit-platform-launcher-1.2.0.jar
For my it was a different problem. Multimodule maven project has two modules A and B, where A is using junit-pioneer:1.9.1 (having transitive dependency from junit-platform-launcher:1.8.2) when module B doesn't use junit-pioneer but fails to build because of java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory when building the whole project with mvn clean install.
My solution was to add (unused) test dependency from junit-pioneer to module B.
So I am running
mvn exec:java -Dexec.mainClass=”com.utm.csc.HTMLParser” -Dexec.args=”http://www.simplehtmlguide.com”
for my Java project. It runs in Eclipse but with the command above, gives me the following errors:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building assignment1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) # assignment1 ---
[WARNING]
java.lang.ClassNotFoundException: ”com.utm.csc.HTMLParser”
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.064 s
[INFO] Finished at: 2016-01-24T16:17:21-05:00
[INFO] Final Memory: 9M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven- plugin:1.4.0:java (default-cli) on project assignment1: An exception occured while executing the Java class. ”com.utm.csc.HTMLParser” -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
This is an image of my paths
I am using OS X El Capitan on a 64-bit MacBook Air mid-2012. What am I doing incorrectly?
The error is that you are giving the argument incorrectly. Your command should be:
mvn clean compile exec:java -Dexec.mainClass=com.utm.csc.HTMLParser -Dexec.args=http://www.simplehtmlguide.com
Notice the lack of quotes. This can be hinted from the error message:
java.lang.ClassNotFoundException: ”com.utm.csc.HTMLParser”
means that somehow, Java searched for a class called ”com.utm.csc.HTMLParser” but it didn't find any, simply because it is actually named com.utm.csc.HTMLParser, without the quotes.
Don't forget to compile first. exec:java doesn't do it by default.
mvn clean compile exec:java -Dexec.mainClass=”com.utm.csc.HTMLParser” -Dexec.args=”http://www.simplehtmlguide.com”
I have been following the hibernate tutorial on http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html
and as others have pointed out in various web boards, it's incomplete.
When I run this command:
mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # hibernate-tutorial ---
[WARNING]
java.lang.ClassNotFoundException: org.hibernate.tutorial.EventManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:722)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.962s
[INFO] Finished at: Sun Sep 30 17:03:34 EDT 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (d
efault-cli) on project hibernate-tutorial: An exception occured while executing
the Java class. org.hibernate.tutorial.EventManager -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
So I think the problem is obvious. When maven executes java, java doesn't know where to find my 'EventManager'. I tried the following on my command line:
set CLASSPATH=C:\Users\robe\Documents\hibernate\project1\src\main\java\org
What else could be wrong here?
Thanks!
I think your classpath is wrong. Try
set CLASSPATH=C:\Users\robe\Documents\hibernate\project1\src\main\java
You don't need the org. That is part of the full qualified class name. The full class name is org.hibernate.tutorial.EventManager
I am not familiar with this tutorial's problem. You may get other classpath errors. If you do you can add more to the class path by separating them by a semi colon.
Also you are setting the classpath in the cmd line. It will only be set for that session so you will have to run your mavem command in the same one. Or set it in your global environment variables
Try running:
mvn clean install
I know it sounds obvious, but when I tried to execute
mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"
I get the same error as you did. But after running mvn clean install the app started (I ran clean install for this code https://github.com/stivlo/hibernate-tutorial, it looks it is the same thing)