这是tomcat启动日志的相关部分:
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应用程序无法正常启动。
任何想法如何解决这个问题?
答案 0 :(得分:6)
显然,这是JDBC提供程序堆栈中的错误。但无论如何,我在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) {}
}
答案 1 :(得分:5)
如果是DBCP问题,那么停止tomcat,杀死任何剩余进程(如果你运行了多个tomcat),删除tomcat临时目录(也许还有工作目录),然后再试一次。
答案 2 :(得分:4)
有关JDBC驱动程序的SEVERE消息是由DBCP问题引起的。见DBCP-332
答案 3 :(得分:4)
有时,特别是在Tomcat上使用Spring应用程序时,错误消息会产生误导 - 当与任何JDBC驱动程序错误无关时,只有某些应用程序BEAN init-method(或@PostConstruct)失败。 错误堆栈跟踪被隐藏,仅出现在tomcat / logs / localhost.xxx中 文件。 请注意这种行为。 这花了我很多时间。
此致 Yosi Lev