Spring batch task pod(jvm) is not automatically terminated after the competition of the task. So, I thought to close the application context explicitly post-completion of the task by closing the context in afterJob method of JobExecutionListener class.
Now context is closed on completion of job but getting some database error -
2023-08-27 18:11:59.348 [main] INFO c.l.r.config.ApplicationShutdownHook - Application is shutting down. Performing cleanup...
2023-08-27 18:11:59.348 [main] INFO c.l.r.config.ApplicationShutdownHook - Cleanup completed. Application is now shutting down.
2023-08-27 18:11:59.363 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown initiated...
2023-08-27 18:11:59.365 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown completed.
2023-08-27 18:11:59.366 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2023-08-27 18:11:59.427 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
2023-08-27 18:12:01.539 [main] INFO o.s.b.c.l.support.SimpleJobLauncher - Job: [FlowJob: [name=reamortizationJob]] failed unexpectedly and fatally with the following parameters: [{run.id=125}]
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
It looks like the Hikari pool is closed prematurely and there are some Bean is trying to get a connection after the pool has been closed.
How can I solve it? Please help me to address it.
Spring batch task pod(jvm) is not automatically terminated after the competition of the task. So, I thought to close the application context explicitly post-completion of the task by closing the context in afterJob method of JobExecutionListener class.
Application context should be gracefully closed after completion of task but is is throwing error relate to HikariPool-1.