解决: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"方式运行jar包时都能正常运行。报错信息如下:

To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

为了防止内存泄漏,已强制注销JDBC驱动程序。

开发环境

Spring Boot + MySql + Spring Security + Druid + Mybatis-Plus

  1. Spring Boot版本:2.1.8.RELEASE
  2. JDBC版本:8.0.18
  3. Druid版本:1.1.20
  4. Tomcat版本:8.X
解决方法

概述:保证部署环境和开发环境一致,即独立Tomcat的版本和IDEA中的Tomcat版本保持一致

为了解决这个问题,我花费了两天时间查找各种资料,但用尽了各种方法都没能解决问题。就在快要绝望的时候,我想到独立的Tomcat会报错,但是IDEA中的Tomcat却可以正常启动,是不是因为两者的版本不同导致的?

于是开始用以下的方法排查问题:

  1. 在IDEA中启动Application,查看Tomcat版本:(9.0.24)
  2. 查看独立Tomcat版本:(8.5.32)

    可以看到两者的版本号不同,所以我去Tomcat官网下载了版本号为9.0.X的Tomcat,然后将war包部署到webapps中,启动Tomcat。这次没有报错,问题解决!

                  .-~~~~~~~~~-._       _.-~~~~~~~~~-.
              __.'              ~.   .~              `.__
            .'//                  \./                  \\`.
          .'//                     |                     \\`.
        .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
      .'//.-"                 `-.  |  .-'                 "-.\\`.
    .'//______.============-..   \ | /   ..-============.______\\`.
  .'______________________________\|/______________________________`.
                               手动分割线
具体错误信息


错误大致有以下几个:

  1. The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
  2. The web application [] registered the JDBC driver [com.mysql.cj.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.
  3. The web application [] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak.

所以从字面意义上可以看出,报错原因大致为:

Web应用程序注册了JBDC驱动程序[com.mysql.cj.jdbc.Driver],但在Web应用程序停止时未能注销它。为了防止内存泄漏,已强制注销JDBC驱动程序。

网上给出的错误原因是:

从6.0.24版本开始,Tomcat附带了内存泄漏检测功能,当webapp中存在与JDBC 4.0兼容的驱动程序时,该漏洞又会导致这种警告消息,该驱动程序会在使用API启动webapp的过程/WEB-INF/lib中自动进行注册,但是在webapp关闭期间未自动注销自身。

网上给出的几种解决方案:(都未能解决我的问题,可能是错误原因不同)

  1. 降级到Tomcat 6.0.23或更早的版本。
  2. 将JDBC驱动程序移至Tomcat的/lib文件夹,并具有连接池数据源来管理驱动程序。
  3. 将Tomcat安装目录中下的server.xml文件中的 标签全部注释掉,并将将reloadable="true"改为 false。

原文地址:https://www.cnblogs.com/imdeveloper/p/12061037.html
转载请注明出处,谢谢!

原文地址:https://www.cnblogs.com/imdeveloper/p/12061037.html

时间: 2024-07-31 02:20:19

解决: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 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 unregiste

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单独发布项目,就出现了以下的错误. 严重: Context [/wangxin] startup failed due to previous errors 八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc 严重: T

To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

1.错误描述 严重: The web application [/AMST] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 八

Tomcat出现To prevent a memory leak, the JDBC Driver has been forcibly unregistered.问题的一种情况记录

问题出现背景: 最近重构了一个老的项目,这个项目中间曾经参与维护的人比较多,代码非常乱,所以对其进行了一次小的重构和升级,将系统环境从JDK1.6+Tomcat6+WindowsServer升级JDK1.8+Tomcat8+Linux,但是重构完成的时候出现了错误,Tomcat一直无法启动. 错误信息 To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 这个错误: 参考的资料 参考了stack ove

[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 JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDB

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.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8809"]21-Sep-2017 23:05:39.352 INFO [Thread-5] org.apache.catalina.core.Stand

解决 Tomcat reload WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but fail

转自:http://www.cnblogs.com/interdrp/p/5632529.html 我的错误如下: 06-Sep-2016 18:57:10.595 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [] registered the JDBC driver [com.mysql.jdbc.

严重: The web application [] registered the JDBC driver 错误

近日发现启动tomcat的时候报如下警告: 2014-9-16 10:25:26 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 严重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.

tomcat启动过程报the JDBC Driver has been forcibly unregistered问题的修复过程

最近两天在整理关于flume的总结文档,没有启动过tomcat.昨天晚上部署启动,发现报了如题的错误,全文如下: 严重: The web application [/oa-deploy] registered the JBDC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] but failed to unregister it when the web application was stopped. To prevent a mem