registered the JDBC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the
严重: The web application [/testweb] registered the JDBC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Google Answers
|
Since version 6.0.24, Tomcat ships with a memory leak detection feature, which in turn can lead to this kind of warning messages when there's a JDBC 4.0 compatible driver in the webapp's What can you do?
|
I found that implementing a simple destroy() method to de-register any JDBC drivers works nicely.
- /**
- * Destroys the servlet cleanly by unloading JDBC drivers.
- *
- * @see javax.servlet.GenericServlet#destroy()
- */
- public void destroy() {
- String prefix = getClass().getSimpleName() +" destroy() ";
- ServletContext ctx = getServletContext();
- try {
- Enumeration<Driver> drivers = DriverManager.getDrivers();
- while(drivers.hasMoreElements()) {
- DriverManager.deregisterDriver(drivers.nextElement());
- }
- } catch(Exception e) {
- ctx.log(prefix + "Exception caught while deregistering JDBC drivers", e);
- }
- ctx.log(prefix + "complete");
- }
I will add to this something I found on the Spring forums. If you move your JDBC driver jar to the tomcat lib folder, instead of deploying it with your webapp, the warning seems to disappear. I can confirm that this worked for me
http://forum.springsource.org/showthread.php?87335-Failure-to-unregister-the-MySQL-JDBC-Driver&p=334883#post334883

浙公网安备 33010602011771号