While looking into #19385, we've found that we're registering the application context shutdown hook even for Servlet deployments. This is unnecessary and we should disable this. We should let the Servlet container manage the application lifecycle.

Comment From: PascalSchumacher

After this change (Auto)Closeable beans like database connection pools of WAR deployments are no longer destroyed when the servlet container is shutdown, or am I missing something?

Comment From: bclozel

The Servlet container should be responsible for shutting down resources when undeploying applications or shutting down completely. Servlets are closed through their destroy() method - Spring's FrameworkServlet is using that hook to close the application context.

I've tested this against Apache Tomcat and this works as expected when shutting down the server. How is your container being shut down?