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 3.2.0-RC1 application fails on JDK with CRaC but without a dependency on org.crac:crac #38186

Closed
vpavic opened this issue Nov 2, 2023 · 2 comments
Labels
type: regression A regression from a previous release
Milestone

Comments

@vpavic
Copy link
Contributor

vpavic commented Nov 2, 2023

I ran into this problem while starting to prepare for Spring Boot 3.2 upgrade on one of the project's I'm currently working on. The problem is reproducible on simplest possible Spring Boot application based on 3.2.0-RC1 that doesn't use CRaC but runs on JDK with CRaC. Such setup results in the following error:

java.lang.NoClassDefFoundError: org/crac/management/CRaCMXBean
	at org.springframework.boot.SpringApplication$CoordinatedRestoreAtCheckpointStartup.restoreTime(SpringApplication.java:1712) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at org.springframework.boot.SpringApplication$CoordinatedRestoreAtCheckpointStartup.startTime(SpringApplication.java:1717) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at org.springframework.boot.SpringApplication$Startup.started(SpringApplication.java:1673) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
	at sample.SampleApplication.main(SampleApplication.java:23) ~[main/:na]
Caused by: java.lang.ClassNotFoundException: org.crac.management.CRaCMXBean
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
	... 7 common frames omitted

I ran into this by building the project on GitHub Actions and using Zulu JDK 17, and in such environment the JDK variant with CRaC will be installed:

- name: Setup Java
  uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
  with:
    distribution: zulu
    java-version: 17
Run actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
  with:
    distribution: zulu
    java-version: 17
    java-package: jdk
    check-latest: false
    server-id: github
    server-username: GITHUB_ACTOR
    server-password: GITHUB_TOKEN
    overwrite-settings: true
    job-status: success
    token: ***
Installed distributions
  Trying to resolve the latest version from remote
  Resolved latest version as 17.0.9+9
  Trying to download...
  Downloading Java 17.0.9+9 (Zulu) from https://cdn.azul.com/zulu/bin/zulu17.46.27-ca-crac-jdk17.0.9-linux_x64.tar.gz ...
  Extracting Java archive...
  /usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/773f714d-7c59-474f-a621-8c5b286e19a9 -f /home/runner/work/_temp/8a30c149-7c8d-4d3e-aa83-3b8ee6c3520e
  Java 17.0.9+9 was downloaded
  Setting Java 17.0.9+9 as the default
  Creating toolchains.xml for JDK version 17 from zulu
  Writing to /home/runner/.m2/toolchains.xml
  
  Java configuration:
    Distribution: zulu
    Version: 17.0.9+9
    Path: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.9-9/x64

It seems that the cause for this is the following code in SpringApplication that makes an assumption that CRaC will be used (and that org.crac.management.CRaCMXBean is available on the classpath) simply on presence of jdk.crac:

static Startup create() {
return (!ClassUtils.isPresent("jdk.crac.management.CRaCMXBean", Startup.class.getClassLoader()))
? new StandardStartup() : new CoordinatedRestoreAtCheckpointStartup();
}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 2, 2023
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 3, 2023
@wilkinsona wilkinsona added this to the 3.2.x milestone Nov 3, 2023
@wilkinsona wilkinsona changed the title Spring Boot 3.2.0-RC1 application fails on JDK with CRaC Spring Boot 3.2.0-RC1 application fails on JDK with CRaC but with a dependency on org.crac:crac Nov 3, 2023
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.0 Nov 3, 2023
@vpavic
Copy link
Contributor Author

vpavic commented Nov 3, 2023

I assume updated issue title should say without a dependency on org.crac:crac.

@wilkinsona wilkinsona changed the title Spring Boot 3.2.0-RC1 application fails on JDK with CRaC but with a dependency on org.crac:crac Spring Boot 3.2.0-RC1 application fails on JDK with CRaC but without a dependency on org.crac:crac Nov 3, 2023
@wilkinsona
Copy link
Member

It should indeed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants