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.
一.
一个web应用程序注册的JBDC驱动程序[com.mysql.jdbc.Driver],但Web应用程序时停止时未能注销。为了防止内存泄漏,JDBC驱动程序已被强行注册。
解决办法 :
在服务器保持运行的状态中,redeploy这个项目, 就出现了异常,
要stop之后 再redeploy,就可以了【先将tomcat kill掉,等进程完全死了,再重新启动】
二.
tomcat 6.0.33启动时,报错
he web application [/aaa] registered the JDBC driver [com.ibm.db2.jcc.DB2Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
在网上搜索得知,一般是项目应用到了SSH组合会出这种问题,多半是Hibernate版本问题。
原因是Hibernate3.2.3已经包含hibernate-annotations-3.2.1.GA.jar,错误在于我重新加入了Annotation.jar等jar文件 ,一般如果用集成开发环境,如Eclipse,MyEclipse等,他会自带有hibernate等框架的jar包,如果我们自己再加入相同的框架(但版本不同)的jar包,就容易引起冲突【这个方法没有试,具体去掉哪些包,不知道。。。】
三.
经查发现开发环境的tom为6.0.20,而出错的生产环境为6.0.29(据查6.0.24、6.0.26均会出现此问题)遂重装tomcat6.0.20解决,此问题的tom只要不高过6.0.20都可以,如6.0.18【没有试验】
四.
使用Sping org.apache.commons.dbcp.BasicDataSource 配置数据源时警告
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.
问题是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()
import java.sql.DriverManager;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
public class FixedBasicDataSource 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();
}
}
然后用 FixedBasicDataSource 替换spring配置文件中的数据源bean的class【我用的c3p0的数据库连接池的包】
分享到:
相关推荐
SEVERE: The web application [/xxx] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has...
严重: The web application [/img] 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...
In the age of the Internet, building a web application is no longer a tough task, but building the web application in the right way is not a trait mastered by many. Building a Web Application with ...
The Pivotal Certified Spring Web Application Developer Exam: A Study Guide is the ideal preparation for the exam and after reading and using it, you'll be able to pass and become a certified Spring ...
Through a review of recent Web application breaches, the book will expose the prolific methods hackers use to execute Web attacks using common vulnerabilities such as SQL Injection, Cross-Site ...
This driver is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform Standard Edition 5 (Java SE 5) and ...
The Tangled Web:A Guide to Securing Modern Web Application美国一位大牛的2011最新作品。从最基本的HTTP协议讲起...很不错。如果你是网络安全技术爱好者,如果你是WEB程序员...我都希望此书对你有帮助...
WebApplication1.zip
The Web Application hackers book!!!!!!!!!
How to Build a Web Dynpro Application
Web Application Design
Web压力测试工具 web application stress tool 1.1
The authors are professional penetration testers who have been involved in web application security for nearly a decade. They have presented training courses at the Black Hat security conferences ...
The Web Application Developer’s Guide presents some of the technologies available for developing web-based multi-tier applications. A web application is a collection of HTML/XML documents, web ...
Java EE Web Application Primer Building Bullhorn A Messaging App with JSP, Servlets, JavaScript, Bootstrap and Oracle 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请...
Learn the Yii application development framework by taking a step-by-step approach to building a Web-based project task tracking system from conception through production deployment Jeffrey Winesett
Ext.NET Web Application DevelopmentExt.NET Web Application DevelopmentExt.NET Web Application DevelopmentExt.NET Web Application DevelopmentExt.NET Web Application DevelopmentExt.NET Web Application ...
From the risk assessment phase to the proof of concept phase, the book details a secure web application development process. The authors provide in-depth implementation guidance and best practices for...