Environment
- spring-boot 2.3.4.RELEASE
- ubuntu 16.04.1 4.15.0 x86_64
Background
After executing the kill -15 <pid> command, my spring-boot application has error log Failed to stop bean 'webServerGracefulShutdown' during the shutdown process.
and the error cause by shutdown process lasted for 1 minute. In normal, I think it only takes a few seconds to complete graceful shutdown.
Could you kindly please help me to resolve the exception?
Error log
`
2023-12-26 23:38:04.402 INFO [SpringContextShutdownHook] org.quartz.core.QuartzScheduler.standby(QuartzScheduler.java:585): Scheduler quartzScheduler_$_NON_CLUSTERED paused.
2023-12-26 23:38:04.414 WARN [SpringContextShutdownHook] o.s.c.s.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:264): Failed to stop bean 'webServerGracefulShutdown'
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/springframework/boot/web/server/GracefulShutdownResult
at org.springframework.boot.web.servlet.context.WebServerGracefulShutdownLifecycle.stop(WebServerGracefulShutdownLifecycle.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:238)
at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:53)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:377)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:210)
at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:128)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1022)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:949)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/web/server/GracefulShutdownResult
... 9 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.web.server.GracefulShutdownResult
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 9 common frames omitted
2023-12-26 23:38:34.415 INFO [SpringContextShutdownHook] o.s.c.s.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:387): Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000ms: [webServerGracefulShutdown]
2023-12-26 23:38:34.426 WARN [SpringContextShutdownHook] o.s.c.s.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:264): Failed to stop bean 'webServerStartStop'
java.lang.NoClassDefFoundError: org/apache/catalina/Lifecycle$SingleUse
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:269)
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:496)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:273)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:331)
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.stop(WebServerStartStopLifecycle.java:51)
at org.springframework.context.SmartLifecycle.stop(SmartLifecycle.java:117)
at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:238)
at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:53)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:377)
at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:210)
at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:128)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1022)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:949)
2023-12-26 23:39:04.427 INFO [SpringContextShutdownHook] o.s.c.s.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:387): Failed to shut down 1 bean with phase value 2147483646 within timeout of 30000ms: [webServerStartStop]
2023-12-26 23:39:04.428 INFO [SpringContextShutdownHook] o.s.s.quartz.SchedulerFactoryBean.destroy(SchedulerFactoryBean.java:845): Shutting down Quartz Scheduler
2023-12-26 23:39:04.428 INFO [SpringContextShutdownHook] org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:666): Scheduler quartzScheduler_$_NON_CLUSTERED shutting down.
2023-12-26 23:39:04.428 INFO [SpringContextShutdownHook] org.quartz.core.QuartzScheduler.standby(QuartzScheduler.java:585): Scheduler quartzScheduler_$_NON_CLUSTERED paused.
2023-12-26 23:39:04.429 INFO [SpringContextShutdownHook] org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:740): Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete.
2023-12-26 23:39:04.438 INFO [SpringContextShutdownHook] o.s.s.c.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:218): Shutting down ExecutorService 'threadPoolTaskScheduler'
2023-12-26 23:39:04.441 INFO [SpringContextShutdownHook] o.s.s.c.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:218): Shutting down ExecutorService 'redisStreamThreadPoolTaskExecutor'
2023-12-26 23:39:04.448 INFO [SpringContextShutdownHook] o.s.s.c.ExecutorConfigurationSupport.shutdown(ExecutorConfigurationSupport.java:218): Shutting down ExecutorService 'threadPoolTaskExecutor'
2023-12-26 23:39:04.451 WARN [SpringContextShutdownHook] o.s.b.f.s.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:267): Invocation of destroy method failed on bean with name 'redisConnectionFactory': java.lang.NoClassDefFoundError: org/springframework/data/util/Optionals
2023-12-26 23:39:04.452 WARN [SpringContextShutdownHook] o.s.b.f.s.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:349): Destroy method 'shutdown' on bean with name 'lettuceClientResources' threw an exception: java.lang.NoClassDefFoundError: io/netty/util/concurrent/ImmediateEventExecutor
2023-12-26 23:39:04.454 INFO [SpringContextShutdownHook] c.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:2003): {dataSource-1} closing ...
2023-12-26 23:39:04.458 WARN [SpringContextShutdownHook] o.s.b.f.s.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:349): Destroy method 'close' on bean with name 'druid' threw an exception: java.lang.NoClassDefFoundError: com/alibaba/druid/pool/DruidDataSource$2
Comment From: wilkinsona
Spring Boot 2.3.4 has been out of support since May 2021. Please upgrade to Spring Boot 3.1.x or later. If the problem remains, please provide a minimal sample that reproduces it and we will re-open this issue and take another look.