registered the JDBC driver [com.mysql.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.
2017-03-23 09:33
686 查看
问题是tomcat的版本问题,tomcat新检测机制导致的这个问题,换版本可以解决问题,但不建议这么做,租用服务器不是你说换就换的。
其实问题根源是BasicDataSource,BasicDataSource类close()的一个Bug。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 [com.mysql.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.
解决方法:继承org.apache.commons.dbcp.BasicDataSource 重写close()
[/code]
然后用 BasicDataSourceExt 替换spring配置文件中的数据源bean的class
其实问题根源是BasicDataSource,BasicDataSource类close()的一个Bug。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 [com.mysql.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.
解决方法:继承org.apache.commons.dbcp.BasicDataSource 重写close()
package cn.com.do1.component.common.jdbc;
import org.apache.commons.dbcp.BasicDataSource;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
/**
* Created by ao.ouyang on 15-11-18.
*/
public class BasicDataSourceExt extends BasicDataSource {
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public synchronized void close() throws SQLException {
DriverManager.deregisterDriver(DriverManager.getDriver(url));
super.close();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
}
}
[/code]
然后用 BasicDataSourceExt 替换spring配置文件中的数据源bean的class
相关文章推荐
- 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.
- The web application [ ] registered the JDBC driver [net.sourceforge.jtds.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver
- registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.
- [tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped
- registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. (转)
- application registered the JDBC driver [com.mysql] but failed to unregister it when the web app...
- The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister i
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered
- 使用DBCP出现registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it
- A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it
- 严重: The web application [/] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregis
- 【解决Tomcat启动异常】To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- To prevent a memory leak, the JDBC Driver has been forcibly unregistered
- registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it
- tomcat 启动时报错:To prevent a memory leak, the JDBC Driver has been forcibly unregistered