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

ClassNotFoundException when running in JDK24 on ARM #44918

Closed
dmkeen opened this issue Mar 27, 2025 · 12 comments
Closed

ClassNotFoundException when running in JDK24 on ARM #44918

dmkeen opened this issue Mar 27, 2025 · 12 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@dmkeen
Copy link

dmkeen commented Mar 27, 2025

I'm not sure if this is a JDK issue or Spring Boot, but I am unable to run a simple Spring Boot application when running on JDK24 on an ARM machine. When I say "simple" application, I literally mean I ran the Spring Initializr and built the jar.

Spring Initializr settings: Maven build, Java language, Spring Boot 3.4.4 (also tried 3.5.0-M3), jar packaging, Java 21 (also tried 24), no extra dependencies.

I uploaded this application to a Raspberry Pi 3 and ran it with "java -jar demo-0.0.1-SNAPSHOT.jar" and it produces a stacktrace similar to the below - the actual class not found varies from run to run.

When I revert to JDK 23.0.2, it runs fine.

Example stacktrace:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/helpers/NOPLoggerFactory
        at org.slf4j.helpers.NOP_FallbackServiceProvider.<init>(NOP_FallbackServiceProvider.java:17)
        at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:105)
        at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:121)
        at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:95)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
        at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:202)
        at com.example.demo.DemoApplication.main(DemoApplication.java:11)
        ... 5 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.helpers.NOPLoggerFactory
        at java.base/java.net.URLClassLoader.findClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:107)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 13 more

Another example stacktrace:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogAdapter
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
        at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:202)
        at com.example.demo.DemoApplication.main(DemoApplication.java:11)
        ... 5 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogAdapter
        at java.base/java.net.URLClassLoader.findClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:107)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 9 more

Output of java --version (tried Liberica and OpenJDK with the same result):

openjdk 24 2025-03-18
OpenJDK Runtime Environment (build 24+37)
OpenJDK 64-Bit Server VM (build 24+37, mixed mode, sharing)

Output of uname -a:

Linux raspberrypi 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 27, 2025
@snicoll
Copy link
Member

snicoll commented Mar 27, 2025

I cannot reproduce with

openjdk version "24" 2025-03-18
OpenJDK Runtime Environment (build 24+36-3646)
OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)

and

Linux kiwi 6.6.67-v8-16k+ #1833 SMP PREEMPT Fri Dec 20 14:15:46 GMT 2024 aarch64 GNU/Linux

That app generated from Spring Initializr starts fine with java -jar demo-0.0.1-SNAPSHOT.jar.

This looks like something on your end but I can't tell why. Can you please have another look and narrow down how we could reproduce it? Also, most of us are on ARM hardware and didn't notice any such issue. A ClassNotFoundException is a high-level Java Runtime exception so I doubt the CPU had anything to do with it.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Mar 27, 2025
@mhalbritter
Copy link
Contributor

mhalbritter commented Mar 28, 2025

I can reproduce it.

╰─$ jdk-24/bin/java -version
openjdk version "24" 2025-03-18
OpenJDK Runtime Environment (build 24+36-3646)
OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing)

╰─$ uname -a
Linux raspberrypi 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux

╰─$ jdk-24/bin/java -jar demo-0.0.1-SNAPSHOT.jar 
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:102)
        at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
        at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/helpers/Reporter
        at org.slf4j.LoggerFactory.safelyInstantiate(LoggerFactory.java:156)
        at org.slf4j.LoggerFactory.findServiceProviders(LoggerFactory.java:134)
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:195)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:187)
        at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:511)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:497)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:446)
        at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog(LogAdapter.java:121)
        at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:95)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
        at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:202)
        at com.example.demo.DemoApplication.main(DemoApplication.java:10)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        ... 4 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.helpers.Reporter
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:349)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:557)
        at org.springframework.boot.loader.net.protocol.jar.JarUrlClassLoader.loadClass(JarUrlClassLoader.java:107)
        at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
        ... 18 more

Even when extracting the JAR archive with -Djarmode=tools extract and then trying to run it fails:

╰─$ ~/jdk-24/bin/java -jar demo-0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/env/Environment
        at com.example.demo.DemoApplication.main(DemoApplication.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.Environment
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490)
        ... 1 more

So it's not something in our loader. I suspect this is a JDK bug.

@dmkeen
Copy link
Author

dmkeen commented Mar 29, 2025

Thanks for that! I have submitted a bug report at https://bugreport.java.com/bugreport/ and will report back when I get a response.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 29, 2025
@mhalbritter
Copy link
Contributor

Here's the JDK bug report: https://bugs.openjdk.org/browse/JDK-8353237

@mhalbritter
Copy link
Contributor

I can't reproduce it running a Debian Linux on qemu on a M1 Mac:

Linux debian-arm 6.1.0-32-arm64 #1 SMP Debian 6.1.129-1 (2025-03-06) aarch64 GNU/Linux
╰─$ ~/jre-24/bin/java -jar demo-0.0.1-SNAPSHOT.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::               (v3.3.10)

2025-03-31T11:32:12.017+02:00  INFO 960 --- [demo] [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT using Java 24 with PID 960 (/home/mhalbritter/demo-0.0.1-SNAPSHOT.jar started by mhalbritter in /home/mhalbritter)
2025-03-31T11:32:12.020+02:00  INFO 960 --- [demo] [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-03-31T11:32:12.273+02:00  INFO 960 --- [demo] [           main] com.example.demo.DemoApplication         : Started DemoApplication in 0.457 seconds (process running for 0.707)

@dmkeen
Copy link
Author

dmkeen commented Mar 31, 2025

Thanks for persisting with this! Yes, I saw that the JDK team were unable to reproduce the issue. Given that they didn’t use the same combination (Linux on AArch64), I submitted feedback and asked whether they could do so.

However with your latest test, it’s starting to almost look specific to the Raspberry Pi.

@mhalbritter
Copy link
Contributor

You're using a Raspberry Pi 3 Model B too?

@snicoll
Copy link
Member

snicoll commented Mar 31, 2025

Rpi5 on my end fwiw

@dmkeen
Copy link
Author

dmkeen commented Mar 31, 2025

You're using a Raspberry Pi 3 Model B too?

Yes I am:
Raspberry Pi 3 Model B Rev 1.2

@mhalbritter
Copy link
Contributor

mhalbritter commented Apr 1, 2025

Bellsoft engineers (with whom I've been in contact with) seems to have found a possible problem and said that they have a workaround:

-XX:+UnlockDiagnosticVMOptions -XX:-UseVectorizedHashCodeIntrinsic

I haven't had the chance to test that yet.

@dmkeen
Copy link
Author

dmkeen commented Apr 1, 2025

Bellsoft engineers (with whom I've been in contact with) seems to have found a possible problem and said that they have a workaround:

-XX:+UnlockDiagnosticVMOptions -XX:-UseVectorizedHashCodeIntrinsic

I haven't had the chance to test that yet.

Hats off to your Bellsoft contacts - adding those flags does indeed resolve the issue! Thank you!

$ java -XX:+UnlockDiagnosticVMOptions -XX:-UseVectorizedHashCodeIntrinsic -jar demo-0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.4.4)

2025-04-02T07:36:28.268+11:00  INFO 84305 --- [demo] [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT using Java 24 with PID 84305 (/home/pi/demo-0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar started by pi in /home/pi)
2025-04-02T07:36:28.291+11:00  INFO 84305 --- [demo] [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-04-02T07:36:32.292+11:00  INFO 84305 --- [demo] [           main] com.example.demo.DemoApplication         : Started DemoApplication in 7.703 seconds (process running for 9.929)

@mhalbritter
Copy link
Contributor

mhalbritter commented Apr 2, 2025

I guess it's now confirmed that this is indeed a JDK bug, so I'm closing this issue. Glad we found a workaround. AFAIU Bellsoft is working on a fix which they'll contribute to OpenJDK.

@mhalbritter mhalbritter added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Apr 2, 2025
@mhalbritter mhalbritter closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants