解决: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 ...
随机推荐
- 201871010126 王亚涛 《面向对象程序设计(Java)》第十一周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...
- 201871010106-丁宣元 《面向对象程序设计(java)》第十一周学习总结
201871010106-丁宣元 <面向对象程序设计(java)>第十一周学习总结 正文开头: 项目 内容 这个作业属于哪个课程 https://home.cnblogs.com/u/nw ...
- C#基础表达式语句详解(上)
本节内容: 1.表达式的定义: 2.各类表达式概览: 3.语句的定义: 4.语句详解: 1.表达式的定义: 1.1什么是表达式: (定义见下图)各类编程语言对表达式的实现不尽相同,但大体上都符合这个定 ...
- opencv旋转图像,90度标准旋转
摘自opencv 源代码 void rotate(InputArray _src, OutputArray _dst, int rotateMode) { CV_Assert(_src.dims() ...
- 【作用域】词法作用域(静态作用域,如:js)、动态作用域(如:.bash脚本)
作用域 作用域是指程序源代码中定义变量的区域. 作用域规定了如何查找变量,也就是确定当前执行代码对变量的访问权限. JavaScript 采用词法作用域(lexical scoping),也就是静态作 ...
- 【Mybatis】CDATA
忽视内部尖括号那些东西
- 流媒体服务器 red5
https://github.com/Red5/red5-server/releases/tag/v1.0.7-RELEASE 打开此链接 再tar包那里 复制链接地址 Wget此链接地址 W ...
- 跑批 - Spring Batch 批处理使用记录
根据spring官网文档提供的spring batch的demo进行小的测验 启动类与原springboot启动类无异 package com.example.batchprocessing; imp ...
- docker的一些常用操作
镜像:一个打包好的应用,还有应用运行的系统.资源.配置等容器:镜像的实例,一个镜像可以有一个或多个实例(容器)对docker容器的变更时写到容器的文件系统的,而不是写到docker镜像中的,可以用一个 ...
- xunit测试无法找到testhost或没有可用测试的问题解决方法
xunit进行测试,需要安装如下几个包: Microsoft.TestPlatform.TestHost Microsoft.NET.Test.Sdk xunit.runner.visualstudi ...