最近项目中遇见一问题,在开发环境没有问题的代码,到了生产环境就会报如下错误:

  严重: 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

 
 

registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. (转)的更多相关文章

  1. 严重: 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

    idea项目启动报如下错误, 网上的方法都试了都没用, 一直没解决, 干掉项目, 重新从svn检出就好了...坑 啊 Root WebApplicationContext: initializatio ...

  2. 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.

    问题是tomcat的版本问题,tomcat新检测机制导致的这个问题,换版本可以解决问题,但不建议这么做,租用服务器不是你说换就换的.其实问题根源是BasicDataSource,BasicDataSo ...

  3. 解决: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.

    问题描述 在将Spring Boot程序打包生成的war包部署到Tomcat后,启动Tomcat时总是报错,但是直接在IDEA中启动Application或者用"java -jar" ...

  4. 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.

    最近使用了最新版的tomcat9,使用jdbc链接mysql数据库.关闭tomcat过程中出现警告 13-Sep-2017 22:22:54.369 WARNING [main] org.apache ...

  5. [tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped

    环境:一个tomcat ,一个工程配置了多数据源,在启动的时候报如下错误: SEVERE: The web application [/qdp-resource-job] registered the ...

  6. 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

    出现以下错误时,我找了很多方法,都未解决,网上有很多,最后我实在无奈,怀疑会不会是Tomcat的原因,更换了一个版本之后就好了.The web application [ ] registered t ...

  7. registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.

    最近在用maven整合SSH做个人主页时候,在eclipse里面使用tomcat7插件发布项目是没有问题的,但当打包成war之后,使用tomcat7单独发布项目,就出现了以下的错误. 严重: Cont ...

  8. The web application [/codeMarket] registered the JBDC driver[.........] but failed to unregister it when the web application was stopped. To prevent

    如果你报错了上面的这个严重,那么你的tomcat版本一定是在6.0.25之上的 原因:tomcat 6.025以后在sever.xml中引入了内存泄露侦测,对于垃圾回收不能处理的对像,它就会做日志. ...

  9. java.lang.ClassNotFoundException:oracle.jdbc.OracleDriver

    在使用JDBC时经常碰到java.lang.ClassNotFoundException:oracle.jdbc.OracleDriver问题 这是jvm找不到驱动类文件,可能是以下原因: 没有导入驱 ...

随机推荐

  1. nginx中配置跨域支持功能

    vi /etc/nginx/nginx.conf 加入如下代码 http {  ###start####  add_header Access-Control-Allow-Origin *;  add ...

  2. android style="@[package:]style/style_name" ----------styles.xml

    android.widget ----XML attribute |____style="@[package:]style/style_name"

  3. 在线程中建立Form遇到的问题

    一个项目由很多Form组成,默认情况下在启动程序时,这些form都会被建立,这会黑屏很长时间,一种方法是用到Form时再建立,结果又发现如果Form设计复杂,建立的过程也会超过1秒以上,于是想到用线程 ...

  4. 《how to design programs》第11章自然数

    这章让我明白了原来自然数的定义本来就是个递归的过程. 我们通常用枚举的方式引出自然数的定义:0,1,2,3,等等(etc).最后的等等是什么意思?唯一能把等等从描述自然数的枚举方法中去除的方法是自引用 ...

  5. Linux系统编程(11)——进程间通信之有名管道

    管道应用的一个重大限制是它没有名字,因此,只能用于具有亲缘关系的进程间通信,在有名管道(named pipe或FIFO)提出后,该限制得到了克服.FIFO不同于管道之处在于它提供一个路径名与之关联,以 ...

  6. 【转】 怎么刷入BOOT.IMG(刷机后开机卡在第一屏的童鞋请注意)-------不错不错

    原文网址:http://bbs.gfan.com/android-3440837-1-1.html 之前呢,有好多机油问我关于刷机卡屏的问题,我解答了好多,但一一解答太费事了,在这里给大家发个贴吧.其 ...

  7. STL中map与hash_map容器的选择收藏

    这篇文章来自我今天碰到的一个问题,一个朋友问我使用map和hash_map的效率问题,虽然我也了解一些,但是我不敢直接告诉朋友,因为我怕我说错了,通过我查询一些帖子,我这里做一个总结!内容分别来自al ...

  8. bootstrap绿色大气后台模板下载[转]

    From:http://www.oschina.net/code/snippet_2364127_48176 1. [图片] 2. [文件] 素材火官网后台模板下载.rar ~ 4MB     下载( ...

  9. LeeCode-Remove Duplicates from Sorted List

    Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...

  10. SQL Server 中使用参数化Top语句

    在T-Sql中,一般top数据不确定的情况下,都是拼sql,这样无论是效率还是可读性都不好.应该使用下面参数化Top方式:declare @TopCount int set @TopCount = 1 ...