16

Here's the relevant portion of the tomcat startup log:

SEVERE: Context [/f360] startup failed due to previous errors
Apr 8, 2010 6:45:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [org.apache.derby.jdbc.ClientDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Apr 8, 2010 6:45:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Apr 8, 2010 6:45:56 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: A web application registered the JBDC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

The problem that it causes is that it basically causes the web app to fail to startup properly.

Any ideas how to fix this?

Laran Evans
  • 1,283
  • 5
  • 15
  • 31
  • Startup failed due to *previous* errors. Please update your question to include those errors. They are the **root cause** of this problem. – BalusC Apr 09 '10 at 19:01
  • 2
    The problem is that there are no errors listed before that. There are only INFO messages. – Laran Evans Apr 16 '10 at 17:54

4 Answers4

6

Sometimes, especially when using Spring application on Tomcat, the error message is misleading - when there is no relation to any JDBC driver error at all but only a failure of some application BEAN init-method (or @PostConstruct). The error stack trace is hidden and appears only in tomcat/logs/localhost.xxx file. Just be aware of this behavior. It costed me a lot of time.

Regards, Yosi Lev

ylev
  • 2,313
  • 1
  • 23
  • 16
  • This is true. When deploying my Grails application (which uses the Spring Framework) it has the database password compiled in the conf/DataSource.groovy file. Of course I was using the wrong password but the only error reported was this bizarre registration of the JDBC driver. No other database error is logged. There must be an option for Spring to log verbose all database startup operations. – Salvador Valencia Oct 23 '15 at 21:34
  • It is true.The real reason is nothing about jdbc. – flower Jul 11 '16 at 03:28
  • This cost me hours! Thanks Yosi Lev – FuzZ63 Aug 25 '17 at 03:06
5

If it's the DBCP problem then stop tomcat, kill any remaining process (in case you have more than one tomcat running), delete the tomcat temp directory (and perhaps work directory) and try again.

Doug
  • 61
  • 1
  • 2
  • This really helped me. I tried killing tomcat, rebooting, everything. When I shut down, deleted the temp dir, and then started back up, everything worked :-) Thanks! – jpswain Jun 06 '11 at 23:11
5

Clearly this is a bug in the JDBC provider stack. But anyway, I used some similar code in Jetty:

public class CleanupContextListener implements ServletContextListener {
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        Logger logger = Logger.getLogger("CleanupContextListener");
        Enumeration<Driver> drivers = DriverManager.getDrivers();
        while (drivers.hasMoreElements()) {
            Driver driver = drivers.nextElement();
            ClassLoader driverclassLoader = driver.getClass().getClassLoader();
            ClassLoader thisClassLoader = this.getClass().getClassLoader();
            if (driverclassLoader != null && thisClassLoader != null &&  driverclassLoader.equals(thisClassLoader)) {
                try {
                    logger.warn("Deregistering: " + driver);
                    DriverManager.deregisterDriver(driver);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {}    
}
Lii
  • 11,553
  • 8
  • 64
  • 88
Mond Raymond
  • 320
  • 1
  • 4
  • 9
4

The SEVERE messages regarding JDBC drivers are caused by a DBCP issue. See DBCP-332

rgielen
  • 176
  • 7