由于jdbc驱动加载,Tomcat无法启动 [英] Tomcat fails to start because of jdbc driver loading

查看:54
本文介绍了由于jdbc驱动加载,Tomcat无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是tomcat启动日志的相关部分:

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.

它导致的问题是基本上导致web应用无法正常启动.

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

有什么想法可以解决这个问题吗?

Any ideas how to fix this?

推荐答案

显然这是 JDBC 提供程序堆栈中的一个错误.但无论如何,我在 Jetty 中使用了一些类似的代码:

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) {}    
}

这篇关于由于jdbc驱动加载,Tomcat无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆