Hi
We tried to run sample Spring Boot web application (generated from start.spring.io) when virtual threads are enabled:
spring.threads.virtual.enabled=true
Here's Dockerfile:
FROM eclipse-temurin:21-jre-alpine
ADD target/demo-0.0.1-SNAPSHOT.jar app.jar
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
However when after we build Docker image and run Docker container we got an exception on startup:
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:91)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:53)
at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:54)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication$AbandonedRunException
at org.springframework.boot.SpringApplication.run(SpringApplication.java:332)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325)
at com.example.demo.DemoApplication.main(DemoApplication.java:12)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication$AbandonedRunException
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:104)
at org.springframework.boot.loader.launch.LaunchedClassLoader.loadClass(LaunchedClassLoader.java:91)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
If we switch off virtual threads support:
spring.threads.virtual.enabled=false
then Spring Application runs successfully inside Docker container. If we just run Spring Boot application locally (with virtual threads enabled) then everything is also fine.
Spring Boot: 3.2.0.RC1 JDK:21
Comment From: wilkinsona
It's not a perfect fit but I wonder if this is another symptom of https://github.com/spring-projects/spring-boot/issues/38050. Please try with 3.2.0-SNAPSHOT (available from https://repo.spring.io/snapshot) and let us know if that helps.
Comment From: sergey-morenets
It's not a perfect fit but I wonder if this is another symptom of #38050. Please try with 3.2.0-SNAPSHOT (available from https://repo.spring.io/snapshot) and let us know if that helps.
Hi @wilkinsona
Thank you for the quick answer. Switching to SNAPSHOT (RC2) version resolved this issue.
Comment From: wilkinsona
Great! Thanks for letting us know.