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
严重: The web application [/wangxin] 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.
八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/wangxin] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/wangxin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/wangxin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/wangxin] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak.
八月 16, 2017 7:29:12 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
严重: The web application [/wangxin] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
这个错误的意思是:在tomcat7启动时候,tomcat自带的一个内存检查的监听器发现,你的项目使用了一个数据库的连接池,并没有关闭的情况下,又去注册了一个连接池,为了保证内存不泄露,所以不允许你项目进行部署.
理论上,使用了SSH框架去整合了数据库,使用了jpa和c3P0连接池,是根本不需要去关心是要去关闭连接和GC的,但是还是报错,对此,就很有疑问了.
网上给出的理论是,因为tomcat7采用了一个监听技术,所以就会这样,完全可以关闭.但事实上,我关闭了之后,虽然启动不报错了,但是还是部署不了,日志里面还是这个错误.
同样的,网上还说了一个方法,就是把数据库的jar包放到tomcat的lib下面,我试了还是没用.
最后层层排查,发现,错误出现在了我的applicationContext.xml上,为了方便开发,我把applicationContext.xml里面的jdbc方面全部提取出来,放到了一个性的applicationContext-jdbc.xml文件里面,并且在总的xml里面使用了<import>标签去插入.
然后,我发现我的web.xml文件配置有点不同,即spring的监听器的classpath配置错误
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml</param-value>
</context-param>
我在classpath那边配置多加了一个*这就导致了
正确的代码:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
由于多配了一个*,这就导致了当启动加载的时候,先加载了applicationContext-jdbc的内容,然后再加载applicationContext的内容,当加载appliactionContext的时候,再次去加载里面<import>标签导入的applicationContext-jdbc内容,这就造成了一次项目加载了两次数据库的连接池,因此造成了重复加载,项目无法启动的问题.
对于web.xml的配置,在这里我还得说一个非常骚气的问题.
不知先前什么情况,在WEF-INF下自动生成了一个classes文件夹,然后文件夹里面竟然多了一个applicationContext文件(理论上编译时候,生成到target里面的WEF-INF文件夹下),这就造成了,当修改resource里面的xml文件时候,没有修改到classes里面的文件,于是悲剧的一幕发生了:
使用SSH框架整合,使用SpringJPA整合的时候,写了一个action,action里面是使用的注解,注入的service,service里面用注解注入的dao,dao只写了一个接口,接口继承了JpaRepository.
使用junit直接调用service里面方法,能获取到数据库里面的数据,而使用tomcat运行的话,调用action获取不到数据.根本不报错,使用debug发现,运行过程中,并没有注入service以及dao.即都是null.
结果原因就是:在maven项目中的classes文件夹下面,自动将resource全部复制过来,而在mavenresource里面的配置文件是修改过的,这就导致了,junit和tomcat运行时候采用的applicationContext.xml文件不同,导致了这个错误.而同时,在web.xml中,配置spring的监听器使用的是
<param-value>classpath*:applicationContext.xml</param-value>
即加载所有classpath下面的xml文件,这就造成了一种情况,就是在junit时候能加载spring自动注入,而使用tomcat却加载不了,同时还不会报错....
就这两个关于web.xml的错误,与君共勉!
registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.的更多相关文章
- 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 ...
- 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 * 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 ...
- [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 ...
- 解决: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" ...
- 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 ...
- 严重: 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 ...
- 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中引入了内存泄露侦测,对于垃圾回收不能处理的对像,它就会做日志. ...
- 解决 01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.jdbc.D
01-Jul-2016 10:49:05.875 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoade ...
随机推荐
- vue知识点2018.6.3
文件夹和文件名称 简介 build 构建脚本目录 config 应用程序的配置文件 index.html 入口页面 node_modules 存放 NPM 依赖模块 package-lock.json ...
- windows测试模式
测试模式通常意义就是让windows 操作系统在测试状态下运行,windows操作系统在这种模式下可以运行非官方或无数字签名的驱动程序 . 目录 1 定义 2 进入/退出windows测试模式方法 ...
- ldap 使用 问题参考
Q2.ldapsearch查询一个有30000多条记录时出现:Size limit exceeded 4 A2:服务器端配置文件有sizelimit 1000的限制!用管理员身份查询-D"c ...
- ajax——用ajax写用户注册
zhuce.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w ...
- PHP多进程编程(一)
虽然PHP 中,多进程用的比较的少.但是毕竟可能是会用到了.我最近就遇到这样一个问题,用户提交几百个url以后,要读出这个url 中的标题. 当然,你不希望用户等待的太久,10s 钟应该给出个答案.但 ...
- 线段树 + 字符串Hash - Codeforces 580E Kefa and Watch
Kefa and Watch Problem's Link Mean: 给你一个长度为n的字符串s,有两种操作: 1 L R C : 把s[l,r]全部变为c; 2 L R d : 询问s[l,r]是 ...
- java----Servlet的生命周期
Servlet生命周期分为三个阶段: 1,初始化阶段 调用init()方法 2,响应客户请求阶段 调用service()方法 3,终止阶段 调用destroy()方法 Servlet初始化阶段: 在 ...
- 登陆Oracle11g的企业管理器
本地:https://localhost:1158/em/ 如果远程:那么把localhost换成服务器IP
- CSS之各种居中
本博客讨论居中情况设定为 总宽度不定,内容宽度不定 的情况.(改变大小时,仍然居中). 特别说明:在元素设置 position:absolute; 来设置居中效果时,除去博客下介绍的css3方法外,还 ...
- hdu 3905(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3905 思路:dp[i][j]表示前i分钟,睡了j分钟收获的的最大价值,并记tmp_dp[i][j]为从 ...