Diagnosing web application shutdown issues
I have a RESTFul application that is deployed on Glassfish 4 that does not properly shut down. An exception is thrown when the application is undeployed and it shows on the Glassfish applications panel as a stack trace. And though it appears upon refresh that the application is no longer deployed, subsequent redeploys fail because the old application has left behind some garbage that is not gone until Glassfish is stopped and restarted.
I could paste the stack trace, and maybe I will if that is what the folks want to see here. My feeling is that after the web container shuts down, there are still threads running that haven't cleaned up properly that may be trying to access resources that are no longer available. I've seen this before with other web containers such as Tomcat, and I've installed clean up filters that forcibly clean up connection pools and ThreadLocal variables. It's ugly and brute-force, and in this latest case, not working to allow a proper shutdown. As a result, I cannot redeploy through any automatic mechanism built-in to, for instance, the maven deploy plugin. It's a manual process until I can work this out.
So, I'd like some advice on how to debug and find this issue. Problem is, once the web container has been shut down, I lose my remote debug connection. Ideally I could issue what by all accounts seems like a web container shutdown to cause my web application to go through all the motions of a shutdown to see what the issue is. Beyond that, I need help with a strategy. I think the issue is around either EHCache or JPA/Eclipselink.
None of this is code I wrote--it's inherited so a large part of it is unknown to me as of yet.
If you have suggestions, I would greatly appreciate them.