After upgrading to openjdk 17, test cases are failing with error
Exception in thread "closer-shutdown-hook" java.lang.NoClassDefFoundError: org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton at org.apache.maven.plugin.surefire.booterclient.ForkStarter$CloseableCloser.run(ForkStarter.java:209) at java.base/java.lang.Thread.run(Thread.java:833)
Full trace
**Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /builds/some-module && /opt/jdk-17.0.7+7/bin/java '-javaagent:/root/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/org.jacoco.agent-0.8.8-runtime.jar=destfile=/builds/path/target/jacoco.exec,append=true -Duser.language=en -Dfile.encoding=UTF-8 -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+ParallelRefProcEnabled -XX:MaxHeapSize=2g -Xmx2g --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.function=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.xni=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED org.apache.maven.surefire.booter.ForkedBooter /builds/path/target/surefire 2024-03-14T15-01-53_612-jvmRun2 surefire7317203603829991286tmp surefire_113447887520135489243tmp
Error occurred in starting fork, check output in log
Process Exit Code: 137
Crashed tests:
org.TestClass
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork (ForkStarter.java:748)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.access$700 (ForkStarter.java:121)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$1.call (ForkStarter.java:393)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$1.call (ForkStarter.java:370)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
[ERROR]
[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
Exception in thread "closer-shutdown-hook" java.lang.NoClassDefFoundError: org/apache/maven/plugin/surefire/booterclient/output/InPluginProcessDumpSingleton
at org.apache.maven.plugin.surefire.booterclient.ForkStarter$CloseableCloser.run(ForkStarter.java:209)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.booterclient.output.InPluginProcessDumpSingleton
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 2 more**
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<!-- surefire (unit tests runner) arguments -->
<propertyName>surefireJacocoArgs</propertyName>
<includes>
<include>org.somepackage.*</include>
</includes>
</configuration>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- report output dir -->
<outputDirectory>target/jacoco-reports</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<failIfNoTests>false</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/*File.java</exclude>
</excludes>
<runOrder>alphabetical</runOrder>
<rerunFailingTestsCount>5</rerunFailingTestsCount>
<argLine>
${surefireJacocoArgs} ${argline-add-open}
</argLine>
</configuration>
</plugin>
</plugins>
</build>
Previously i was on openjdk 11, same used to work. suspecting issue is with maven surefire plugin incompatible with java 17. i even upgraded surefire to latest version still faced same issue
Update 1
After removing useSystemClassLoader flag, now i see another error
Process exit code --> 137 issue related to memory
ExecutionException The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd /builds/modules/module1 && /opt/jdk-17.0.7+7/bin/java '-javaagent:/root/.m2/repository/org/jacoco/org.jacoco.agent/0.8.8/org.jacoco.agent-0.8.8-runtime.jar=destfile=/builds/modules/module1/target/jacoco.exec,append=true -Duser.language=en -Dfile.encoding=UTF-8 -Xmx5g --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util.function=ALL-UNNAMED --add-opens java.base/java.util.stream=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.xni=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.xni.parser=ALL-UNNAMED --add-opens java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens java.base/java.nio.file=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED org.apache.maven.surefire.booter.ForkedBooter /builds/modules/module1/target/surefire 2024-03-14T10-28-32_626-jvmRun4 surefire8889132164816018609tmp surefire_1182817604224050150tmp
Error occurred in starting fork, check output in log
Process Exit Code: 137
Crashed tests:
SomeTestClass
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.awaitResultsDone(ForkStarter.java:532)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkOnceMultiple(ForkStarter.java:405)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:321)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:266)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1314)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932)
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)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
useSystemClassLoaderfrom the configuration withmaven-surefire-plugin:3.2.5? If that still fails, sharing a minimal example would be a good idea.