spring-boot: NoClassDefFoundError when shutting down the application
my springboot version is 3.0.9. when I use Lininx shell ‘kill -15 pid’ to kill my java application, it reported some exception like these:
2024-10-29 09:51:50 28484242 [SpringApplicationShutdownHook] WARN o.s.c.s.DefaultLifecycleProcessor - Failed to stop bean 'webServerGracefulShutdown'
java.lang.NoClassDefFoundError: org/springframework/boot/web/server/GracefulShutdownCallback
at org.springframework.boot.web.context.WebServerGracefulShutdownLifecycle.stop(WebServerGracefulShutdownLifecycle.java:62)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:235)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:374)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:207)
at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:130)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1068)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:173)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1027)
at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:139)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:108)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.web.server.GracefulShutdownCallback
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:440)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
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(ClassLoader.java:520)
... 12 common frames omitted
This error doesn’t happen every time, it just happens occasionally, and I don’t even know how to reproduce this problem. I am very certain that this class ‘org.springframework.boot.web.server.GracefulShutdownCallback’ exists.
Thanks for help.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 29 (11 by maintainers)
I try to create a temp branch and remove all my business code. I will let it run for a few days and see if the error still exists.
Sorry, I didn’t express clearly. I just wanted to supplement the operating environment that previously reported errors. After the upgrade, there will be no problems on any operating system. @philwebb
I upgraded springboot’s version to 3.2.11. After running the program for 13 hours, I just restarted it and there won’t be any errors. I will observe for a few more days. Many thanks.
OK, I’ll give it a try. I’ll run the program for a few hours and see the results tomorrow.