registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. (轉)


最近項目中遇見一問題,在開發環境沒有問題的代碼,到了生產環境就會報如下錯誤:

 

  嚴重: 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. 
 
一開始以為是數據庫賬號密碼錯誤,或數據庫鏈接不上,因為這兩個原因也確實會報這個錯,可是通過確認發現不是以上兩個原因引起的,當時真的是百思不得其解,后來通過一步步的排查和測試,發現,以前生產、測試、開發環境的數據庫都是集群形式的,我們配的也是集群形式多個節點的數據庫鏈接,如下:
jdbc.url=jdbc:oracle:thin:@(DESCRIPTION=(FAILOVER = yes)(ADDRESS = (PROTOCOL = TCP)(HOST =XXX.XXX.XXX.XXX)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST =XXX.XXX.XXX.XXX)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = cedb)))
 
而我們新建的這一台生產環境連的數據庫是直連的,沒有做數據庫集群,所以加載鏈接的時候報如上錯誤,把鏈接的配置設置如下即可:
jdbc.url=jdbc\:oracle\:thin\:@XXX.XXX.XXX.XXX\:1521\:cedb
 
這次的異常真的是受教了,希望可以幫到有一樣困惑的朋友。
 
 
 
 

今天開始學習了struts2, 於是下了最新的版本struts2.2.3.1,在使用的過程中總是報錯:A web application created a ThreadLocal with key of type , 盡管出現了這個錯誤,但是並不妨礙程序正常運行, 雖然程序雖然能正常運行,但是看的這個錯誤很是別扭,所以網上搜了一下看看,也就有了下面這篇文章

struts2關於A web application created a ThreadLocal with key of type 異常解決辦法 

 

created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@12c74b9]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1a34544]) but failed to remove it。。。。

這類問題的解決辦法:

       http://confluence.atlassian.com/pages/viewpage.action?pageId=218275753

看看老外的這篇,好像就是在講這個問題,原因大概是說tomcat 6.025之后引入了一種內存泄露的檢查機制,會把不能垃圾收集的對像做日志。

第一種解決辦法:

使用低於6版本的tomcat

 

第二種解決辦法:

在tomcat的server.xml文件(在tomcat的安裝路徑下的conf文件夾里)中把

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>

這個監聽給關了。

就是用<!--。。。-->把下面三句話括起來就可以啦。

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />        <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />        <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

http://blog.csdn.net/zhuhezan/article/details/6882089

 

Description

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.

I was able to fix it by overriding close method this way:

public class XBasicDataSource extends BasicDataSource { @Override public synchronized void close() throws SQLException { DriverManager.deregisterDriver(DriverManager.getDriver(url)); super.close(); } } 

but I think it should be probably the default behavior of BasicDataSource. Or perhaps there should be some flag/setting on BasicDataSource, named "deregisterDriverAtClose" or so.

https://issues.apache.org/jira/browse/DBCP-332

 

 

 

 

 

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. 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. 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. 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. 解決: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 [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDB [tomcat啟動報錯]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped 啟動錯誤筆記:DruidDriver] but failed to unregister it when the web application was stopped,To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Registered driver with driverClassName=oracle.jdbc.driver.OracleDriver was not found 錯誤: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.
 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM