We have several MemoryLeaks (found in the catalina.out file), reloading the context.
To clear these threads, I created an implementation of ServletContextListener.
The method is contextInitialized()successfully called when creating the context, because I can see the log entries.
But the method is contextDestroyed()not being called, so my cleanup code is not being called. Any ideas why this is happening?
Do I have to implement another interface that I need to notice when I need to reload the context?
public class MyContextListener implements ServletContextListener {
private static final Logger log = Logger.getLogger(MyContextListener.class);
@Override
public void contextDestroyed(final ServletContextEvent arg0) {
MyContextListener.log.info("destroying Servlet Context");
MyContextListener.log.info("Servlet Context destroyed");
}
@Override
public void contextInitialized(final ServletContextEvent arg0) {
try {
MyContextListener.log.info("Creating Servlet Context");
} finally {
MyContextListener.log.info("Servlet Context created");
}
}
}
source
share