Hi everyone, I noticed a problem with one of my web applications which requires some cleanup when shutdown. It seems this cleanup isn't happening even if everything has been put in the contextDestroyed() method of my web listener. So, to debug this problem I wrote a minimal web listener and tested to see what is going on. It seems the contextDestroyed() method isn't called when stopping the web application or stopping the Tomcat instance.
Here is my minimal code: package some.thing; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @WebListener public class TestContext implements ServletContextListener { private Logger log = LogManager.getLogger(); public TestContext() { log.info("Constructor"); } @Override public void contextDestroyed(ServletContextEvent arg0) { log.info("Context destroyed."); } @Override public void contextInitialized(ServletContextEvent arg0) { log.info("Context initialized."); } } The constructor's info and the contextInitialized() info are both written to my log file, the info from the contextDestroyed() method is missing. I am running Tomcat 8.0.32 with Java 1.8.0.74, but I have seen a similar behavior with Tomcat 6.0.24 and Java 1.6.0.91 as well. I am using log4j 2.5. I find it difficult to believe this is a bug in Tomcat, so, I guess I am doing something wrong. Someone can provide some guidance to identify the cause of such undesirable behavior? Regards, ----------------- Daniel Savard --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org