I had the same problem, and as Jeff says, βdonβt worry about itβ wasnβt.
I made a ServletContextListener that stops the freezing thread when closing the context, and then registered such a ContextListener in the web.xml file.
I already know that stopping the thread is not an elegant way to deal with them, but otherwise the server continues to crash after two or three deployments (it is not always possible to restart the application server).
The class I created:
public class ContextFinalizer implements ServletContextListener { private static final Logger LOGGER = LoggerFactory.getLogger(ContextFinalizer.class); @Override public void contextInitialized(ServletContextEvent sce) { } @Override public void contextDestroyed(ServletContextEvent sce) { Enumeration<Driver> drivers = DriverManager.getDrivers(); Driver d = null; while(drivers.hasMoreElements()) { try { d = drivers.nextElement(); DriverManager.deregisterDriver(d); LOGGER.warn(String.format("Driver %s deregistered", d)); } catch (SQLException ex) { LOGGER.warn(String.format("Error deregistering driver %s", d), ex); } } Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]); for(Thread t:threadArray) { if(t.getName().contains("Abandoned connection cleanup thread")) { synchronized(t) { t.stop();
After creating the class, register it in the web.xml file:
<web-app... <listener> <listener-class>path.to.ContextFinalizer</listener-class> </listener> </web-app>
Oso Sep 16 '12 at 5:16 2012-09-16 05:16
source share