解决: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
- Spring Boot版本:2.1.8.RELEASE
- mysql-connector-java版本:8.0.18
- Druid版本:1.1.20
- Tomcat版本:8.X
解决方法
概述:保证部署环境和开发环境一致,即独立Tomcat的版本和IDEA中的Tomcat版本保持一致
为了解决这个问题,我花费了两天时间查找各种资料,但用尽了各种方法都没能解决问题。就在快要绝望的时候,我想到独立的Tomcat会报错,但是IDEA中的Tomcat却可以正常启动,是不是因为两者的版本不同导致的?
于是开始用以下的方法排查问题:
- 在IDEA中启动Application,查看Tomcat版本:(9.0.24)

- 查看独立Tomcat版本:(8.5.32)

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

错误大致有以下几个:
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.
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.
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关闭期间未自动注销自身。
网上给出的几种解决方案:(都未能解决我的问题,可能是错误原因不同)
- 降级到Tomcat 6.0.23或更早的版本。
- 将JDBC驱动程序移至Tomcat的/lib文件夹,并具有连接池数据源来管理驱动程序。
- 将Tomcat安装目录中下的server.xml文件中的 标签全部注释掉,并将将reloadable="true"改为 false。
解决: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 [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 ...
- 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 ...
- 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 ...
- 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 ...
- 严重: 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 ...
- 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 ...
- 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中引入了内存泄露侦测,对于垃圾回收不能处理的对像,它就会做日志. ...
- [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 ...
- 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 ...
随机推荐
- Delphi-基础(例程、例程返回值)
一.例程:Delphi中独有的称呼,例程是将具体某个功能的代码进行封装表现形式: 1.过程 2.函数 过程和函数的区别在于有没有返回值二.例程的作用 1.可以解决命名冲突问题 2.提高代码的重复使用率 ...
- 个人第2次作业:熟悉使用Git工具
GIT地址 https://github.com/dxg1999 GIT用户名 dxg1999 学号后五位 62317 个人博客 我的博客 作业链接 作业内容 项目作业的整个过程 作业背景 阿超家里的 ...
- luogu P1904 天际线
分析 都知道是从左向右扫描 可是该维护什么,扫描什么? 注意想想怎么输出, 实际上它要的输出就是图形的轮廓,即每个突出块的左上节点的x,y 所以说, 我们可以把扫描线扫进的楼房放入线段树,扫出的楼房删 ...
- 201871010117-石欣钰《面向对象程序设计(JAVA)》第十四周学习总结
项目 内容 这个作业属于哪个课程 <https://home.cnblogs.com/u/nwnu-daizh/> 这个作业的要求在哪里 <https://www.cnblogs.c ...
- HTML与CSS学习笔记(2)
1.CSS背景样式? background-color 背景色 background-image 背景图 url(背景地址) 默认:会水平垂直铺满背景图 background-repeat 平铺方式 ...
- 【Web】URL解析
Request = { QueryString: function (item) { var svalue = location.search.match(new RegExp("[\?\& ...
- java修饰符的总结
引言:Java的修饰符根据修饰的对象不同,分为类修饰符.方法修饰符.变量修饰符,其中每种修饰符又分为访问控制修饰符和非访问控制修饰符.访问控制存在的原因:a.让客户端程序员无法触及他们不应该触及的部分 ...
- JavaMap常用操作
判断key值是否存在 map.containsKey("youkey") 根据key修改value值 map.put("youkey","you ne ...
- 网络yum源配置
系统环境:CentOS7 [1] 首先备份/etc/yum.repos.d/CentOS-Base.repo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum ...
- JAVA基础概念(二)
一.java修饰符和使用场景 修饰符是用来定义类.方法或者变量的访问权限,分为两大类: 访问修饰符: 限定类.属性.方法是否可以被程序里其他部分访问和调用. private<default< ...