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 ...
随机推荐
- python WSGI框架详解
1.web应用的本质1)浏览器发送一个HTTP请求2)服务器收到请求,生成一个HTML文档3)服务器把HTML文档作为HTTP响应的body发个浏览器4)浏览器收到HTTP响应,从HTTP Body取 ...
- DOM节点的三个属性
在文档对象模型 (DOM) 中,每个节点都是一个对象.DOM 节点有三个重要的属性 : 1. nodeName : 节点的名称 2. nodeValue :节点的值 3. nodeType :节点的类 ...
- [systemd]Linux系统启动之systemd
参照:https://wiki.debian.org/systemd 最近在添加板子应用程序自启动的时候,发现在rcN.d中的符号链接并没有用,文件系统为Debian Jessie 8, 后来从同事那 ...
- EasyUI Window和Layout
我们建立tabs内容. <div class="easyui-window" title="Layout Window" icon="icon- ...
- 集中精力的重要性(The Importance of Focus)
集中精力的重要性(The Importance of Focus) 在当今激烈竞争的经济中,你需要集中精力使得你公司的独特方面精益求精.并且你需要每天将精力集中在改进你的公司上.通过终极外包,单干型企 ...
- 关于Unity的C#基础学习(二)
一.Debug的使用 int a=3; Debug.Log("a="+a); 二.整数的定义 int m; Debug.Log(m); //C#比C更严谨,没有初始化的变量打印出 ...
- Spring Framework 官方文档学习(三)之Resource
起因 标准JDK中使用 java.net.URL 来处理资源,但有很多不足,例如不能限定classpath,不能限定 ServletContext 路径. 所以,Spring提供了 Resource ...
- 在JAVA中利用public static final的组合方式对常量进行标识
在JAVA中利用public static final的组合方式对常量进行标识(固定格式). 对于在构造方法中利用final进行赋值的时候,此时在构造之前系统设置的默认值相对于构造方法失效. 常量(这 ...
- HMLocationEvent
HMLocationEvent *locEvent = [[HMLocationEvent alloc] initWithRegion:region1]; region1.notifyOnEntry ...
- 漫游kafka实战篇之搭建Kafka开发环境(3)
上篇文章中我们搭建了kafka的服务器,并可以使用Kafka的命令行工具创建topic,发送和接收消息.下面我们来搭建kafka的开发环境. 添加依赖 搭建开发环境需要引入kafka的jar包 ...