Hi. Im having trouble with the jdkToolchain feature of maven-surefire-plugin https://maven.apache.org/surefire/maven-surefire-plugin/examples/toolchains.html This is my working build tag
<build> <pluginManagement> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <jdkToolchain> <version>9</version> </jdkToolchain> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <artifactId>maven-toolchains-plugin</artifactId> <executions> <execution> <configuration> <toolchains> <jdk> <version>9</version> </jdk> </toolchains> </configuration> </execution> </executions> </plugin> </plugins> </build> I can build with the above config no problem, but if I configure the compile plugin with <target>9</target>, surefire throws > Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed: java.lang.UnsupportedClassVersionError: com/etc/common/crypto/clientreference/TestClientToken has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 In either case I can see the toolchain being configured in the build log [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ cryptocommon --- [INFO] Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/zulu-9-amd64] [INFO] Changes detected - recompiling the module! [INFO] Compiling 7 source files to /git/tep22x/common_cryptocommon/target/test-classes [INFO] [INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ cryptocommon --- [INFO] Toolchain in maven-surefire-plugin: JDK[/usr/lib/jvm/zulu-9-amd64] Now, if on top of my changes thus far I go and configure surefire-plugin with <forkCount>1</forkCount>, it's back to a successful build. But, if I follow the advice of https://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html and rather set <forkCount>0</forkCount>, I get this [ERROR] Exception in provider [ERROR] org.apache.maven.surefire.booter.SurefireExecutionException: Exception in provider [ERROR] at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:91) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1295) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159) [ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932) [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.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:196) [ERROR] at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:186) [ERROR] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [ERROR] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [ERROR] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [ERROR] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [ERROR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [ERROR] at java.lang.Thread.run(Thread.java:748) [ERROR] Caused by: java.lang.UnsupportedClassVersionError: com/traderoot/common/crypto/clientreference/TestClientToken has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class f ile versions up to 52.0 [ERROR] at java.lang.ClassLoader.defineClass1(Native Method) [ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:756) [ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) [ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:74) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:369) [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:363) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [ERROR] at org.apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:100) [ERROR] at org.apache.maven.surefire.api.util.DefaultScanResult.loadClass(DefaultScanResult.java:136) [ERROR] at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:100) [ERROR] at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:147) [ERROR] at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128) [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.surefire.api.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:167) [ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:161) [ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:84) [ERROR] at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:87) [ERROR] ... 16 more I don't like guessing what is going on here, but i'm not in a position to go that extra mile and "Run Maven with -Dmaven.surefire.debug, and attach to the running process with a debugger." In a nutshell my question is "how can I build with a JDK 9 or above using a toolchain and without being limited to a single test fork?" Thanks, Delany