yuanhaoliang 发表于 2015-8-9 08:41:25

Tomcat 6.0.32 +Spring dbcp datasource关闭Tomcat出现严重异常

  异常如下:



信息: Pausing Coyote HTTP/1.1 on http-8080
2014-3-6 14:52:50 org.apache.catalina.core.StandardService stop
信息: Stopping service Catalina
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application registered the JDBC driver but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak.
2014-3-6 14:52:50 org.apache.coyote.http11.Http11Protocol destroy
信息: Stopping Coyote HTTP/1.1 on http-8080
INFO org.springframework.context.support.AbstractApplicationContext.doClose(1002) | Closing Root WebApplicationContext: startup date ; root of context hierarchy
INFO org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(345) | Stopping beans in phase 2147483647
INFO org.quartz.core.QuartzScheduler.standby(556) | Scheduler scheduler_$_yanshiying-PC1394088762202 paused.
INFO org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(422) | Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1ac7fbb: defining beans ; root of factory hierarchy
INFO org.springframework.scheduling.quartz.SchedulerFactoryBean.destroy(760) | Shutting down Quartz Scheduler
INFO org.quartz.core.QuartzScheduler.shutdown(635) | Scheduler scheduler_$_yanshiying-PC1394088762202 shutting down.
INFO org.quartz.core.QuartzScheduler.standby(556) | Scheduler scheduler_$_yanshiying-PC1394088762202 paused.
INFO org.quartz.core.QuartzScheduler.shutdown(707) | Scheduler scheduler_$_yanshiying-PC1394088762202 shutdown complete.
  Tomcat版本为:6.0.32
  spring数据源配置如下:




      
      

   

  原因:https://issues.apache.org/jira/browse/DBCP-332
  BasicDataSource's method close() doesn't deregister JDBC driver. This causes permgen memory leaks in web server environments, during context reloads. For example, using Tomcat 6.0.26 with Spring, and BasicDataSource declared in Spring context, there is a message printed at web application reload:
  SEVERE: A web application registered the JBDC driver but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
  解决方法:



import java.sql.DriverManager;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
/**
* 解决 关闭Tomcat时报错:the JDBC driver but failed to unregister it when the web application was stopped
* @author*/
public class WzhBasicDataSource extends BasicDataSource{
@Override
public synchronized void close() throws SQLException {
DriverManager.deregisterDriver(DriverManager.getDriver(url));
super.close();
}
}
  
  
页: [1]
查看完整版本: Tomcat 6.0.32 +Spring dbcp datasource关闭Tomcat出现严重异常