I am using Tomcat (10.1), JPA, Hibernate (6.4.4) and H2 (2.2.224) to provide persistence within a webapp.
When the app is updated, Tomcat shuts down, deploys and restarts. This causes problems because the Hibernate connection pool thread and H2 threads are not stopped cleanly when the app stops.
I have a ServletContextListener
which gets informed when the shut down occurs. I tried closing the EntityManagerFactory
but this seemed to prevent it from being reopened.
What do I have to do to cleanly stop and restart Hibernate and H2?