Maven compiler plugin Unsupported major.minor version
Hi, I hope this is the right channel. I have a multi module project that I'm trying to modularize in the JPMS sense. It's configured to run maven with java 11 and run the compiler plugin using java 15 through the toolchain plugin and this is what I get: [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ pdfblack-model --- [INFO] Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-15.0.1+9] [INFO] [INFO] BUILD FAILURE [INFO] [INFO] Total time: 1.141 s [INFO] Finished at: 2021-02-05T18:07:26+01:00 [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project pdfblack-model: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Unsupported major.minor version 59.65535 -> [Help 1] I attached the full stacktrace at the bottom. It seems to me the plugin is using jdk11 to do something where it should use jdk15 from the toolchain but before digging deeper I wanted to double check if I'm doing anything wrong or if maybe my expectations are wrong. This is my configuration, nothing special there: org.apache.maven.plugins maven-compiler-plugin 3.8.1 15 --enable-preview This is the stacktrace: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Unsupported major.minor version 59.65535 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) 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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:566) 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.plugin.PluginExecutionException: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Unsupported major.minor version 59.65535 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148) 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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
Re: Maven compiler plugin Unsupported major.minor version
Thanks for the reply. I tried that and I got: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project pdfblack-model: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile: org/codehaus/plexus/languages/java/jpms/ResolvePathsResult$ModuleNameSource [ERROR] - [ERROR] realm =plugin>org.apache.maven.plugins:maven-compiler-plugin:3.8.1 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/home/torakiki/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.8.1/maven-compiler-plugin-3.8.1.jar [ERROR] urls[1] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-java/0.9.11/plexus-java-0.9.11.jar [ERROR] urls[2] = file:/home/torakiki/.m2/repository/org/ow2/asm/asm/7.0-beta/asm-7.0-beta.jar [ERROR] urls[3] = file:/home/torakiki/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar [ERROR] urls[4] = file:/home/torakiki/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar [ERROR] urls[5] = file:/home/torakiki/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar [ERROR] urls[6] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.4/plexus-utils-2.0.4.jar [ERROR] urls[7] = file:/home/torakiki/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar [ERROR] urls[8] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar [ERROR] urls[9] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.7.1/plexus-component-annotations-1.7.1.jar [ERROR] urls[10] = file:/home/torakiki/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar [ERROR] urls[11] = file:/home/torakiki/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[12] = file:/home/torakiki/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.2.1/maven-shared-utils-3.2.1.jar [ERROR] urls[13] = file:/home/torakiki/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar [ERROR] urls[14] = file:/home/torakiki/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar [ERROR] urls[15] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.8.4/plexus-compiler-api-2.8.4.jar [ERROR] urls[16] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.8.4/plexus-compiler-manager-2.8.4.jar [ERROR] urls[17] = file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] - I get this error even if I move plexus-java up of one minor version to plexus-java 0.9.11. I also tried to update asm with: org.ow2.asm asm 9.1 so pexus-java 0.9.10 and asm latest but I got the same original error. Andrea On 2021/02/07 20:19:40, Benjamin Marwell wrote: > Hi Andrea, > > looking at the maven-compiler-plugin, it uses plexus-java 0.9.10 which > in turn uses an old 6.x asm version. > > Try adding a more recent version of plexus-java (which uses asm 9.0) > and see if that works. > > org.apache.maven.plugins > maven-compiler-plugin > 3.8.1 > > 15 > > --enable-preview > > > > org.codehaus.plexus > plexus-java > 1.0.6 > > > > If it works, please kindly open a ticket at > http://issues.apache.org/jira/projects/MCOMPILER with the full stack > trace. > > - Ben > > Am Sa., 6. Feb. 2021 um 08:47 Uhr schrieb Andrea Vacondio > : > > > > Hi, > > I hope this is the right channel. > > I have a multi module project that I'm trying to modularize in the JPMS > > sense. > > It's configured to run maven with java 11 and run the compiler plugin using > > java 15 through the toolchain plugin and this is what I get: > > > > [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ > > pdfblack-model --- > > [INFO] Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-15.0.1+9] > > [INFO] > > > > [INFO] BUILD FAILURE > > [INFO] > >
Re: Maven compiler plugin Unsupported major.minor version
Ok, I created a super simple repo here https://github.com/torakiki/testme The pom is stripped to the minimum, here are the steps I use to reproduce: - git clone https://github.com/torakiki/testme.git - mvn compile - mvn compile The first compilation works, the second doesn't unless I clean. The error is pretty much the same: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Unsupported major.minor version 59.0 Using Maven 3.6.3 My toolchain.xml: jdk 15 openjdk /usr/lib/jvm/jdk-15.0.1+9 My .mavenrc: export JAVA_HOME=/usr/lib/jvm/jdk-11 I'm on Linux but I tested on Windows 7 and got the same result. A side note, while with this simple project the first compile works, the second doesn't, in my multi-module project with a parent module plus 8 child modules it fails on the second module with 'mvn clean compile' from the parent. I hope it helps. Andrea Il giorno mar 9 feb 2021 alle ore 21:46 Benjamin Marwell < bmarw...@apache.org> ha scritto: > Hi, > > do you have a public repository to share? Have you tried other JVM > implementations? Have you tried cooling without preview features? > > On Mon, 8 Feb 2021, 15:30 Andrea Vacondio, > wrote: > > > Thanks for the reply. I tried that and I got: > > [ERROR] Failed to execute goal > > org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile > > (default-compile) on project pdfblack-model: Execution default-compile of > > goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile > failed: A > > required class was missing while executing > > org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile: > > > org/codehaus/plexus/languages/java/jpms/ResolvePathsResult$ModuleNameSource > > [ERROR] - > > [ERROR] realm = > > plugin>org.apache.maven.plugins:maven-compiler-plugin:3.8.1 > > [ERROR] strategy = > > org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy > > [ERROR] urls[0] = > > > file:/home/torakiki/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.8.1/maven-compiler-plugin-3.8.1.jar > > [ERROR] urls[1] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-java/0.9.11/plexus-java-0.9.11.jar > > [ERROR] urls[2] = > > > file:/home/torakiki/.m2/repository/org/ow2/asm/asm/7.0-beta/asm-7.0-beta.jar > > [ERROR] urls[3] = > > > file:/home/torakiki/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar > > [ERROR] urls[4] = > > > file:/home/torakiki/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar > > [ERROR] urls[5] = > > > file:/home/torakiki/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar > > [ERROR] urls[6] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.4/plexus-utils-2.0.4.jar > > [ERROR] urls[7] = > > > file:/home/torakiki/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar > > [ERROR] urls[8] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar > > [ERROR] urls[9] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.7.1/plexus-component-annotations-1.7.1.jar > > [ERROR] urls[10] = > > > file:/home/torakiki/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar > > [ERROR] urls[11] = > > > file:/home/torakiki/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar > > [ERROR] urls[12] = > > > file:/home/torakiki/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.2.1/maven-shared-utils-3.2.1.jar > > [ERROR] urls[13] = > > > file:/home/torakiki/.m2/repository/commons-io/commons-io/2.5/commons-io-2.5.jar > > [ERROR] urls[14] = > > > file:/home/torakiki/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar > > [ERROR] urls[15] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.8.4/plexus-compiler-api-2.8.4.jar > > [ERROR] urls[16] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.8.4/plexus-compiler-manager-2.8.4.jar > > [ERROR] urls[17] = > > > file:/home/torakiki/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar > > [ERROR] Number of foreign imports: 1 > > [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: > > null]] > > [ERROR] > > [ERROR] -
Re: Maven compiler plugin Unsupported major.minor version
Hi Benjamin, yes, that simple repo indeed works with version 1.0.6. I also created a simple multi module version and it works as well. Unfortunately I tested on my real life repo and got: Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile: org/codehaus/plexus/languages/java/jpms/ResolvePathsResult$ModuleNameSource >From what I can tell that's happening because ModuleNameSource enum has been moved between plexus-java version used in maven-compiler 3.8.1 and plexus-java 1.0.6. This error doesn't show in the test repos so I assume I'm going into an execution path that is not covered in that repos. Next test I checked out the latest snapshot 3.9.0 of the compiler plugin, installed locally and used that in my real life repo together with plexus-java 1.0.6 and I got a warning and a compilation error: [WARNING] Can't extract module name from classes: Unsupported major.minor version 59.65535 Compilation failure [ERROR] /home/torakiki/repos/pdf-black/pdfblack-model/src/main/java/module-info.java:[20,22] error: module not found: black.pdf.i18n So I managed to set up a test multi module repo with a parent and 2 children where child2 depends on child1 https://github.com/torakiki/test and I get the same result, using maven compiler 3.9.0-SNAPSHOT and plexus-java 1.0.6: [WARNING] Can't extract module name from classes: Unsupported major.minor version 59.0 Compilation failure [ERROR] /home/torakiki/repos/test/testme-child2/src/main/java/module-info.java:[5,17] error: module not found: test.me.child >From what I can see from the logs child1 module is actually missing from the module path. Is there anything misconfigred? Andrea Il giorno gio 11 feb 2021 alle ore 08:42 Benjamin Marwell < bmarw...@apache.org> ha scritto: > Hi Andrea, > > Robert was sure the new plexus dependency fixes your issue. He tried > it, and it worked. Same for me. > > Can you please double check you added the dependency to your *compiler > plugin*, not to the > general dependency section? > > I created a PR so you can see the changes: > https://github.com/torakiki/testme/pull/1 > > This will probably make it into one of the next versions of the > compiler plugin, if you would rather want to wait. > > Best regards, > - Ben > > Am Mi., 10. Feb. 2021 um 14:33 Uhr schrieb Benjamin Marwell > : > > > > Hi Andrea, > > > > thank you very much! I can confirm that this should not happen. > > The error seems to be that the preparePaths method tries to parse the > > existing module-info.class, but does not use the Toolchain provided > > JDK for this. > > > > The issue for this: https://issues.apache.org/jira/browse/MCOMPILER-455 > > cc to the dev mailing list. Issue is free to grab. Probably needs to > > be fixed in plexus java, therefore also created > > https://github.com/codehaus-plexus/plexus-languages/issues/64. > > > > Am Mi., 10. Feb. 2021 um 12:51 Uhr schrieb Andrea Vacondio > > : > > > > > > Ok, I created a super simple repo here > https://github.com/torakiki/testme > > > > > > The pom is stripped to the minimum, here are the steps I use to > reproduce: > > > - git clone https://github.com/torakiki/testme.git > > > - mvn compile > > > - mvn compile > > > > > > The first compilation works, the second doesn't unless I clean. > > > The error is pretty much the same: > > > Execution default-compile of goal > > > org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: > > > Unsupported major.minor version 59.0 > > > > > > Using Maven 3.6.3 > > > My toolchain.xml: > > > > > > > > > jdk > > > > > > 15 > > > openjdk > > > > > > > > > /usr/lib/jvm/jdk-15.0.1+9 > > > > > > > > > > > > My .mavenrc: > > > export JAVA_HOME=/usr/lib/jvm/jdk-11 > > > > > > > > > I'm on Linux but I tested on Windows 7 and got the same result. > > > A side note, while with this simple project the first compile works, > the > > > second doesn't, in my multi-module project with a parent module plus 8 > > > child modules it fails on the second module with 'mvn clean compile' > from > > > the parent. > > > > > > I hope it helps. > > > Andrea > > > > > > Il giorno mar 9 feb 2021 alle ore 21:46 Benjamin Marwell < > > > bmarw...@apache.org> ha scritto: > > > > > > > Hi, > >