问题是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()

  1. package cn.com.do1.component.common.jdbc;
  2. import org.apache.commons.dbcp.BasicDataSource;
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5. import java.sql.SQLFeatureNotSupportedException;
  6. import java.util.logging.Logger;
  7. /**
  8. * Created by ao.ouyang on 15-11-18.
  9. */
  10. public class BasicDataSourceExt extends BasicDataSource {
  11.    @Override
  12.    public <T> T unwrap(Class<T> iface) throws SQLException {
  13.        // TODO Auto-generated method stub
  14.        return null;
  15.    }
  16.    @Override
  17.    public boolean isWrapperFor(Class<?> iface) throws SQLException {
  18.        // TODO Auto-generated method stub
  19.        return false;
  20.    }
  21.    @Override
  22.    public synchronized void close() throws SQLException {
  23.        DriverManager.deregisterDriver(DriverManager.getDriver(url));
  24.        super.close();
  25.    }
  26.    @Override
  27.    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
  28.        return null;
  29.    }
  30. }

然后用 BasicDataSourceExt 替换spring配置文件中的数据源bean的class

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.的更多相关文章

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

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

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

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

  5. 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中引入了内存泄露侦测,对于垃圾回收不能处理的对像,它就会做日志. ...

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

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

  8. [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 ...

  9. Tomcat运行一段时间后,自动停止关闭,To prevent a memory leak,Druid 数据库连接自动关闭, the JDBC Driver has been forcibly unregistered.

    1. Tomcat 错误日志 tail -100f tomcat9/logs/catalina.out 21-Sep-2017 23:05:39.301 INFO [Thread-5] org.apa ...

随机推荐

  1. js 取值&赋值-form表单

      form表单元素介绍 CreateTime--2016年9月22日10:25:54 Author:Marydon <form> 表单元素. 表单中的元素: <input>表 ...

  2. maven 将jar包添加到本地仓库

      maven  如何将jar包添加到本地仓库 CreateTime--2018年4月19日12:50:50 Author:Marydon 情景描述:当项目所需的jar包,maven中央仓库中没有该j ...

  3. uva 699 The Falling Leaves(建二叉树同一时候求和)

    本来看着挺难的.大概是由于我多瞟了一眼题解,瞬间认为简单多了.做题就得这样,多自己想想.如今是 多校联赛,然而我并不会做. .. .慢慢来,一直在努力. 分析: 题上说了做多不会超过80行.所以能够开 ...

  4. Tomcat servers.xml 无注释版

    <?xml version='1.0' encoding='utf-8'?> <Server port="8005" shutdown="SHUTDOW ...

  5. 开源大数据技术专场(上午):Spark、HBase、JStorm应用与实践

    16日上午9点,2016云栖大会“开源大数据技术专场” (全天)在阿里云技术专家封神的主持下开启.通过封神了解到,在上午的专场中,阿里云高级技术专家无谓.阿里云技术专家封神.阿里巴巴中间件技术部高级技 ...

  6. vc 6.0 的sdk下载地址

    很多人在为vc6.0sdk版本太老发愁吧,今天在晚上找了半天,终于找到了下载的地方,和大家分享一下. Windows Server 2003 Platform SDKLast Updated: Feb ...

  7. HDUOJ---2642Stars(二维树状数组)

    Stars Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/65536 K (Java/Others)Total Submi ...

  8. POJ----The Suspects

    The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 18890   Accepted: 9150 Des ...

  9. 关于ftpshell脚本中mget中去除多余交互式提示的方法

    默认情况下ftp里面的交互式提示是开启的,平常如果下载多个文件时,这种提示很让人烦,如果是在shell脚本里面要从ftp服务器上一次mget多个文件,写个交互式很麻烦,最好是把这个交互式提示关掉. 进 ...

  10. SELECT控件add方法 ie 类型不匹配

    s = document.createElement('select'); try{ //for ie8 or earlier s.add(new Option('text','value'),s.o ...