When we are closing the spring boot(3.3.0) application then showing Unexpected exception occurred invoking async method in the log repeated many times. We have used the Spring Scheduler for processing the file.
That issue is coming only Linux machine, on windows machine working fine.
Scheduler configuration
schedulers.thread-pool-size=50
timeout.time-in-minutes=2
schedulers.time-in-milliseconds=10
Exception
2024-09-13T12:07:19.057+02:00 DEBUG 711105 --- [SpringApplicationShutdownHook] o.h.b.r.i.BootstrapServiceRegistryImpl : Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
2024-09-13T12:07:19.058+02:00 INFO 711105 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-09-13T12:07:19.058+02:00 DEBUG 711105 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Before shutdown stats (total=10, active=10, idle=0, waiting=31)
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-28] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-33] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-4] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-43] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-41] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-33] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.060+02:00 DEBUG 711105 --- [pool-3-thread-41] o.s.orm.jpa.EntityManagerFactoryUtils : Opening JPA EntityManager
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-4] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [pool-3-thread-43] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.059+02:00 DEBUG 711105 --- [SpringApplicationShutdownHook] o.m.jdbc.client.impl.StandardClient : aborting connection 202748
2024-09-13T12:07:19.060+02:00 DEBUG 711105 --- [pool-3-thread-42] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.061+02:00 DEBUG 711105 --- [pool-3-thread-42] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.060+02:00 DEBUG 711105 --- [pool-3-thread-32] org.hibernate.internal.SessionImpl : Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed
2024-09-13T12:07:19.061+02:00 DEBUG 711105 --- [pool-3-thread-32] o.s.orm.jpa.JpaTransactionManager : Should roll back transaction but cannot - no transaction available
2024-09-13T12:07:19.059+02:00 ERROR 711105 --- [pool-3-thread-28] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public void com.XXXX.XXXXX.XXXXX.XXX.XXXX.XXXX.processReadySched() throws java.io.IOException
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'dataSourceScriptDatabaseInitializer': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220) ~[spring-beans-6.1.8.jar!/:6.1.8]
I have tried the below properties
taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
taskScheduler.setAwaitTerminationSeconds(10);
New contributor
Deepak Dedha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.