Tomcat 启动异常 [com.alibaba.druid.mock.MockDriver] but failed to unregister it

出错原因: tomcat下面同时放了两个项目

启动时报错,结果是一个项目正常,一个项目不能正常启动

严重: The web application [/inventory] registered the JDBC driver [com.alibaba.druid.mock.MockDriver] but failed to unregister it when the web application was s
topped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

刚开始以为是数据库连接池的bug,不能同时有两个连接池名称相同。尝试修改连接池名称后依然不管用。

并更新连接池jar包到最新包1.1.9, 问题并没有解决

<dependency>
	<groupId>com.alibaba</groupId>
	<artifactId>druid</artifactId>
	<version>1.1.9</version>
</dependency>

无奈之下继续baidu, 发现一遍国外文章 

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

并尝试写一个监听器,在项目销毁时,释放jdbc链接。依然不管用。

 

继续查看报错日志

发现cartalina.out 里面只有这样一个错,但是没有详细的错误信息

One or more listeners failed to start. Full details will be found in the appropriate container log file

于是新增一个日志配置 logging.properties

handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler    

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

org.apache.juli.FileHandler.level = FINE    
org.apache.juli.FileHandler.directory = ../logs    
org.apache.juli.FileHandler.prefix = error-debug.    

java.util.logging.ConsoleHandler.level = FINE    
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

然后会在logs文件下生成一个error-debug的文件查看里面错误信息

严重: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [D:\OPT\apache-tomcat-7.0.96-fh\webapps\fhm_weizu\] instead of [D:\OPT\apache-tomcat-7.0.96-fh\webapps\inventory\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
	at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:163)
	at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:119)
	at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:49)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5197)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5720)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

于是顺藤摸瓜,在web.xml 中增加配置webAppRootKey后,完美解决

<context-param>
  <param-name>webAppRootKey</param-name>
  <param-value>webapp.inventory</param-value>
</context-param>

转载于:https://my.oschina.net/yangshj/blog/3097946

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值