Maven surefire could not find ForkedBooter class
Solution 1
To fix it (in 2018), update your openjdk to the latest version, at least 8u191-b12. In case this issue reappears in 2020, it is likely that the default behavior of openjdk was changed, and you will then need to update the maven surefire plugin.
This was a now fixed bug in the openjdk-8 package (behaviour deviates from upstream significantly without need; missing the upstream patch to revert back to disabling a security check) that you just upgraded to. But it is also a bug in the surefire plugin, SUREFIRE-1588, supposedly fixed in surefire 3.0.0-M1: it apparently is using absolute paths in a place where Java will in the future only allow relative path names (and Debian activated the future behavior already).
The package version 8u181-b13-2 states:
- Apply patches from 8u191-b12 security update.
Note that 191-b12 != 181-b13. The 191-b12 security patches were just out a few days ago, and apparently the maintainers wanted to get them to you fast. Updating completely to 191-b12 will likely need additional testing (well, so should have this upload, apparently).
There had been several workaounds:
- You can install the previous package from snapshots.d.o instead. After downgrading, you can forbid the broken version (if you are using aptitude and not
apt
) usingsudo aptitude forbid-version openjdk-8-jre-headless
. For regular "apt" I didn't see a similar forbid mechanism, so you would likely need to use apt pinning to prevent this upgrade from being reinstalled (or you just keep on downgrading again, I hope this will be resolved soon). - According to bug tracking, setting the property
-Djdk.net.URLClassPath.disableClassPathURLCheck=true
with any of the usual methods (e.g.,JAVA_FLAGS
) should also help. But I have not verified this myself. You can apparently even add the workaround to~/.m2/settings.xml
to get it enabled for all your Maven builds easily.
As you can see, bug tracking works, the issue was narrowed down, and a fixed package is available and a new version of the surefire plugin will come soon!
Solution 2
Set useSystemClassloader to false:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
If you're not inheriting from a parent which has version defined for you (such as the Spring Boot starter) you'll need to define that as well.
Solution 3
I found this workaround and fixed my tests: configure the maven-surefire-plugin
not to use the system classloader.
Solution 4
I have another workaround. Set the environment variable _JAVA_OPTIONS. I've used this for our TeamCity build agents and now our builds run fine.
_JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true
Solution 5
I posted a more targeted variant of one of the above workarounds in JIRA. Add to ~/.m2/settings.xml
:
<profile>
<id>SUREFIRE-1588</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</properties>
</profile>
Related videos on Youtube
Sylordis
Software engineer in Java / C++, hardcore gamer, metalhead, geek, opensource enthusiast, roleplayer and book lover. Sums it up pretty well.
Updated on October 13, 2020Comments
-
Sylordis over 3 years
Recently coming to a new project, I'm trying to compile our source code. Everything worked fine yesterday, but today is another story.
Every time I'm running
mvn clean install
on a module, once reaching the tests, it crashes into an error:[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ recorder --- [INFO] Surefire report directory: /lhome/code/recorder/target/surefire-reports [INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider [INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true ------------------------------------------------------- T E S T S ------------------------------------------------------- Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
and later on:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project recorder: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
I'm running on Debian 9 (Stretch) 64-bits with OpenJDK 1.8.0_181, Maven 3.5.4, working behind my company proxy which I configured in my
~/.m2/settings.xml
.A strange thing it that the latest Surefire version is 2.22.1 if I remember correctly. I tried to specify the plugin version, but it does not get updated, otherwise there's no plugin version specification in any POM (parent, grand-parent or this one).
I managed to force Maven to change the Surefire version to the latest, but now it's even worse:
[INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [...] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project recorder: There are test failures. [ERROR] [ERROR] Please refer to /lhome/code/recorder/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 /bin/sh -c cd /lhome/code/recorder/ && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java '-javaagent:/lhome1/johndoe/.m2/repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runt ime.jar=destfile=/lhome/code/recorder/target/jacoco.exec,append=true,includes=esa/*,excludes=**/api/**/*.class' -jar /lhome/code/recorder/target/surefire/surefirebooter7426165516226884923.jar /lhome/code/recorder/target/surefire 2018-10-26T16-16-12_829-jvmRun1 surefire1721866559613511529tmp surefire_023400764142672144tmp [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 /bin/sh -c cd /lhome/code/recorder/ && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java '-javaagent:/lhome1/johndoe/.m2/repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runt ime.jar=destfile=/lhome/code/recorder/target/jacoco.exec,append=true,includes=esa/*,excludes=**/api/**/*.class' -jar /lhome/code/recorder/target/surefire/surefirebooter7426165516226884923.jar /lhome/code/recorder/target/surefire 2018-10-26T16-16-12_829-jvmRun1 surefire1721866559613511529tmp surefire_023400764142672144tmp [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: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: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:954) [ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) [ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:192) [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)
-
loosetie over 5 yearsI'm having this bug in clircle-ci. Surefire forks and forked vm prints the following message and exits: "Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter". The massage is in target/surefire-reports/*.dumpstream . If you run maven with -X it prints the command line, you can try it and see the vm printing this message.
-
jediz over 5 years
-
Adrian M. over 5 yearsmy solution was to stop using open-jdks of any version. can't afford this kind of unreliability in something so foundational.
-
jogaco over 5 yearsUse maven's
dependencyManagement
section to specify different versions of plugins -
clearlight over 5 yearsUpdating to jdk 11 on Debian was a surefire solution for me!
-
Sylordis over 5 yearsYes, but unfortunately our build was not working with java 11 ;) But that's why I'm doing at other places and it works pretty great too.
-
-
Erich Schubert over 5 years@AdrianMadaras I did not get a new update so far, only the -2 version. There also was no announcement of a fixed upload yet, but its underway. You probably just re-upgraded to the known problematic version.
-
Rob Audenaerde over 5 yearsI just got the same issue on Ubuntu 18.04, using OpenJDK 10.0.2. Switching the JAVA_HOME to my 'java-9-oracle' install fixed it.
-
Rob Audenaerde over 5 yearsBtw that is openjdk-10 bug: bugs.debian.org/cgi-bin/bugreport.cgi?bug=911742
-
mirabilos over 5 yearsHere’s the corresponding issue in the surefire-maven-plugin issue tracker: issues.apache.org/jira/browse/SUREFIRE-1588 (it’s still a bug in the Canonical/Debian backport of the relevant OpenJDK changes).
-
Sylordis over 5 yearsThe problem comes from the latest jdk8 for debian, In my opinion it's better to "fix" the core problem than to try to work around it.
-
Edwin Diaz over 5 yearsWork around 1. doesn't make sense to me as that's the version I'm experiencing the issue on. Overriding the maven-surefire-plugin to not useSystemClassLoader also didn't work
-
amdev over 5 yearsThe sha256 sound tricky and afraid you ? Actually other answer looks more like a work around, disable some feature from surefire, here it's just about use the last working docker image without changing your working pom or pipeline which is a work around.
-
mirabilos over 5 yearsAccording to the maven-surefire-plugin maintainer, all workarounds (this, setting
forkCount
to 0, or settingargLine
globally) have problems and cannot be applied universally. -
Erich Schubert over 5 years@EdwinDiaz-Mendez you should not be seeing this issue on 8u181-b13 -1, only on 8u181-b13 -2 . Because the change was applied in -2. Make sure you didn't upgrade back to -2.
-
Edwin Diaz over 5 years@ErichSchubert
(build 1.8.0_181-8u181-b13-1ubuntu0.18.04.1-b13)
was myjava -version
. I have since moved over the Oracle's JDK and the problem is not present. -
Erich Schubert over 5 yearsFor Ubuntu, the affected package versions contain
-1ubuntu0
, so you have the known bad version installed. You likely want to go back to the August version8u181-b13-1
. But don't ask me where you can find archived versions of Ubuntu packages. Anyway, the easier workaround is #2, obviously. -
Paŭlo Ebermann over 5 yearsThis has the effect of not creating a new VM for running the tests, so the tests can possibly influence the main build VM.
-
dma_k over 5 yearsI confirm that solution (1) works, namely I've downgraded
8u181-b13-2~deb9u1
to8u171-b11-1~deb9u1
and problem disappeared. -
Daniel over 5 yearsSince I'm using Jenkins CI and attempts at reconfiguration fail, I downgraded openjdk-8 to the previous release until the bug is fixed. Thanks for the detailed answer.
-
Erich Schubert over 5 yearsYou can try upgrading to surefire 3.0.0-M1, too. But 2 to a 3 milestone version can of course break other stuff.
-
Nikolai over 5 yearsThis fails with the following warning:
[WARNING] Expected root element 'settings' but found 'profile' (position: START_TAG seen <profile>... @1:9) @ /home/nikolai/.m2/settings.xml, line 1, column 9
-
nealmcb over 5 yearsGood find. But please include the actual workaround text in your post, or at least identify the link clearly as a stackoverflow link. I.e. the approach used by @markoorn is more helpful.
-
qqx over 5 years@Nikolai The above snippet needs to be enclosed in
<settings><profiles>...</profiles></settings>
. -
Gorkk over 5 yearsfor the record, 3.0.0-M1 has been released on November 7, but there might indeed be several things breaking going from 2.22.1 to 3.0.0-M1 (will know soon I guess)
-
berezovskyi over 5 yearsA breaking change labelled as a security fix is usually not introduced for no reason and so that someone tells on SO how to disable it... just sayin'
-
berezovskyi over 5 yearsWhy would anyone suggest to install a version without security patches?! Though other suggestions include skipping tests, huh.
-
flob over 5 yearsYou don't need to anymore :-) It's fixed. But for the meantime I had many java projects which I had to work on and my java runtime was nowhere exposed to any new code from outside. So there was a oversee-able risk that was Ok for me. It's everyone's own decision after all :-)
-
berezovskyi over 5 yearsActually you are right, I found that JDK devs walked back on that prop set by default: hg.openjdk.java.net/jdk/jdk/rev/f54dcfc5a5f8; but major version upgrade to surefire does not seem like the best fix to me, actually.
-
flob over 5 yearsAbsolutely! But the changes they had to make are throughout the whole codebase and very invasive. So a minor version change for this fix wouldn't be an option in surefire.
-
berezovskyi over 5 yearsAnd unfortunately, 2.x is discontinued and we'll have to make a switch sooner than later: issues.apache.org/jira/browse/…
-
Elouan Keryell-Even over 5 years
-
9ilsdx 9rvj 0lo about 5 yearsIs it actually a bug in OpenJDK because of changing the default behaviour of documented parameter, or rather a bug in Surefire because of making assumptions about undocumented parameter?
-
Erich Schubert about 5 years@9ilsdx9rvj0lo As discussed in the bug reports, the jar file format specification requires relative paths, and surefire generated absolute paths. So it is a surefire bug - it generated invalid jars; OpenJDK just began enforcing part of the specification it tolerated before.
-
Hinotori over 4 yearsWhat black magic this jupiter-plugin does? This worked for me! Upvote! :-)
-
tibor17 about 4 yearsEnabling the system classloader is the worst practice due to you are running the tests in plugin process. The right practice is to upgrade the version of every plugin. Maven 3.7.0 will upgrade versions of all plugins which belong to the default life cycle. The Spring should not stick to the old versions and should not override them either. This causes unnecessary conflicts in responsibilities.
-
tibor17 about 4 yearsAlways check a new version in Maven Central. The plugin fixed similar issues in
M2
, etc. Currently available version is3.0.0-M4
and we are awaiting3.0.0-M5
in several days. -
tibor17 about 4 yearsThis is again a bad practice. The right one is to upgrade the version. Always check the versions in Maven Central.
-
tibor17 over 3 yearsUse the latest Surefire version
3.0.0-M5
. This was caused by PID checker. Now the checker is disabled and it can be manually enabled and configured. -
tibor17 over 3 yearsUse the latest Surefire version
3.0.0-M5
. This was caused by PID checker. Now the checker is disabled and it can be manually enabled and configured. -
tibor17 over 3 yearsUse the latest Surefire version
3.0.0-M5
. This was caused by PID checker. Now the checker is disabled and it can be manually enabled and configured. -
tibor17 over 3 yearsUse the latest Surefire version
3.0.0-M5
. This was caused by PID checker. Now the checker is disabled and it can be manually enabled and configured. -
tibor17 over 3 yearsUse the latest Surefire version
3.0.0-M5
. This issue was caused by PID checker in the versions 2.x.x. Now the checker is disabled, and it can be manually enabled and configured.