Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-boot-maven-plugin doesn't work with Java 22 #39927

Closed
krzyk opened this issue Mar 13, 2024 · 5 comments
Closed

spring-boot-maven-plugin doesn't work with Java 22 #39927

krzyk opened this issue Mar 13, 2024 · 5 comments
Labels
type: bug A general bug
Milestone

Comments

@krzyk
Copy link
Contributor

krzyk commented Mar 13, 2024

Steps to reproduce:

  1. Go to https://start.spring.io/
  2. Generate project with Maven and Java 21 (don't change anything else)
  3. Download, unzip
  4. Change <java.version>21</java.version> to <java.version>22</java.version>
  5. Execute mvn clean verify

Results with:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.3:repackage (repackage) on project demo: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:3.2.3:repackage failed: Unsupported class file major version 66 -> [Help 1]

This is because spring-boot-maven-plugin:3.2.3 uses old ASM version 9.5. Easily to see using mvn dependency:resolve-plugins:

...
[INFO]       org.ow2.asm:asm:jar:9.5
[INFO]       org.ow2.asm:asm-commons:jar:9.5
[INFO]       org.ow2.asm:asm-tree:jar:9.5
...
@mhalbritter
Copy link
Contributor

Can reproduce this. Here's the stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.3:repackage (repackage) on project java22: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:3.2.3:repackage failed: Unsupported class file major version 66
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:3.2.3:repackage failed: Unsupported class file major version 66
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 66
    at org.springframework.asm.ClassReader.<init> (ClassReader.java:199)
    at org.springframework.asm.ClassReader.<init> (ClassReader.java:180)
    at org.springframework.asm.ClassReader.<init> (ClassReader.java:166)
    at org.springframework.asm.ClassReader.<init> (ClassReader.java:287)
    at org.springframework.boot.loader.tools.MainClassFinder.createClassDescriptor (MainClassFinder.java:254)
    at org.springframework.boot.loader.tools.MainClassFinder.doWithMainClasses (MainClassFinder.java:216)
    at org.springframework.boot.loader.tools.MainClassFinder.findSingleMainClass (MainClassFinder.java:197)
    at org.springframework.boot.loader.tools.Packager.findMainMethod (Packager.java:351)
    at org.springframework.boot.loader.tools.Packager.findMainMethodWithTimeoutWarning (Packager.java:340)
    at org.springframework.boot.loader.tools.Packager.getMainClass (Packager.java:335)
    at org.springframework.boot.loader.tools.Packager.addMainAndStartAttributes (Packager.java:315)
    at org.springframework.boot.loader.tools.Packager.buildManifest (Packager.java:300)
    at org.springframework.boot.loader.tools.Packager.write (Packager.java:211)
    at org.springframework.boot.loader.tools.Packager.write (Packager.java:204)
    at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:151)
    at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:138)
    at org.springframework.boot.maven.RepackageMojo.repackage (RepackageMojo.java:227)
    at org.springframework.boot.maven.RepackageMojo.execute (RepackageMojo.java:217)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)

@mhalbritter
Copy link
Contributor

Same with 3.3.0-SNAPSHOT.

@mhalbritter mhalbritter changed the title spring-boot-maven-plugin 3.2.3 fails with Java 22 spring-boot-maven-plugin doesn't work with Java 22 Mar 13, 2024
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 13, 2024
@mhalbritter mhalbritter added this to the 3.2.x milestone Mar 13, 2024
@mhalbritter
Copy link
Contributor

mhalbritter commented Mar 13, 2024

The maven plugin uses spring-core:6.0.10:

[INFO]    org.springframework.boot:spring-boot-maven-plugin:maven-plugin:3.3.0-SNAPSHOT:runtime
...
[INFO]       org.springframework:spring-core:jar:6.0.10

but otherwise a current version of the framework dependencies:

[INFO]       org.springframework:spring-context:jar:6.1.5-SNAPSHOT
[INFO]       org.springframework:spring-aop:jar:6.1.5-SNAPSHOT
[INFO]       org.springframework:spring-beans:jar:6.1.5-SNAPSHOT
[INFO]       org.springframework:spring-expression:jar:6.1.5-SNAPSHOT

Is that because of the dependencies on spring-boot-buildpack-platform and spring-boot-loader-tools, which both have 6.0.10 in their POM?

@wilkinsona
Copy link
Member

Oh dear. Those mixed versions are bad. We had to downgrade to Framework 6.0.x in the build plugin-related projects to work around this Gradle bug that's been fixed in Gradle 7.6.4.

As a first step, I think we should try to configure the Maven plugin to consistently use 6.1.x. As a second step, and probably in a separate issue, we'll have to figure out what to do about Gradle. I'm not sure how we can both support Java 22 and Gradle versions < 7.6.4. We could raise the minimum supported version of Gradle for Boot 3.3 but that'd still leave us with a problem in Boot 3.2.x.

@wilkinsona
Copy link
Member

Gradle does not yet support Java 22. 8.7, currently in its RC phase will support using a Java 22 toolchain but won't support running Gradle itself on Java 22. That buys us some time on the Gradle side of things.

@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.4 Mar 13, 2024
ndwlocatieservices added a commit to ndwnu/nls-routing-map-matcher that referenced this issue Dec 4, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [nu.ndw.nls.geometry:nls-geometry](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | compile | patch | `3.2.0` -> `3.2.4` |
| [commons-io:commons-io](https://commons.apache.org/proper/commons-io/) ([source](https://gitbox.apache.org/repos/asf?p=commons-io.git)) | compile | minor | `2.17.0` -> `2.18.0` |
| [org.springframework.boot:spring-boot-starter-parent](https://spring.io/projects/spring-boot) ([source](https://github.com/spring-projects/spring-boot)) | parent | minor | `3.3.5` -> `3.4.0` |

---

### Release Notes

<details>
<summary>spring-projects/spring-boot (nu.ndw.nls.geometry:nls-geometry)</summary>

### [`v3.2.4`](https://github.com/spring-projects/spring-boot/releases/tag/v3.2.4)

[Compare Source](spring-projects/spring-boot@v3.2.3...v3.2.4)

#### ⭐ New Features

-   Add TWENTY_TWO to JavaVersion enum [#&#8203;39825](spring-projects/spring-boot#39825)

#### 🐞 Bug Fixes

-   Thread name prefix is not always set when using virtual threads [#&#8203;39958](spring-projects/spring-boot#39958)
-   spring-boot-maven-plugin doesn't work with Java 22 [#&#8203;39927](spring-projects/spring-boot#39927)
-   Resolving a BuildpackReference created from a URL-like String can fail on Windows [#&#8203;39793](spring-projects/spring-boot#39793)
-   SpringProfile arbiter fails without a Spring's environment [#&#8203;39786](spring-projects/spring-boot#39786)
-   bootStartScripts tasks should be an instance of org.gradle.api.tasks.application.CreateStartScripts rather than its superclass org.gradle.jvm.application.tasks.CreateStartScripts [#&#8203;39764](spring-projects/spring-boot#39764)
-   When using Logback, log messages appear in a single line when application name contains brackets [#&#8203;39564](spring-projects/spring-boot#39564)

#### 📔 Documentation

-   Document support for Java 22 [#&#8203;40046](spring-projects/spring-boot#40046)
-   Fix web session javadoc typo [#&#8203;39821](spring-projects/spring-boot#39821)
-   Fix typo in Custom HTTP Exchange Recording section [#&#8203;39784](spring-projects/spring-boot#39784)
-   Make description of virtual threads and JVM exit easier to understand by removing "no-non" double-negative [#&#8203;39732](spring-projects/spring-boot#39732)

#### 🔨 Dependency Upgrades

-   Upgrade to Angus Mail 2.0.3 [#&#8203;39973](spring-projects/spring-boot#39973)
-   Upgrade to Glassfish JAXB 4.0.5 [#&#8203;39975](spring-projects/spring-boot#39975)
-   Upgrade to Graph...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants