Choose unique values for the 'webAppRootKey' context-param in your web.xml files!

报错日志

tomcat里面跑了多个项目,启动时报如下错误:

严重: The web application [/drc] 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.
十月 17, 2019 9:49:33 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/drc] appears to have started a thread named [Timer-10] but has failed to stop it. This is very likely to create a memory leak.
十月 17, 2019 9:49:33 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/drc] 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.
十月 17, 2019 9:49:33 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/drc] 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.
十月 17, 2019 9:49:33 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/drc] 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.
十月 17, 2019 9:49:33 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/drc] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.

查看localhost.2019-10-17.log日志发现报错如下:

严重: 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' = [/usr/local/apache-tomcat-7.0.55/webapps/mobile/] instead of [/usr/local/apache-tomcat-7.0.55/webapps/drc/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
	at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:151)
	at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:117)
	at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
	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)

日志中字面表述:'webapp.root' = [/usr/local/apache-tomcat-7.0.55/webapps/mobile/] instead of [/usr/local/apache-tomcat-7.0.55/webapps/drc/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
大概意思:webapp.root的这个key的值是 [/usr/local/apache-tomcat-7.0.55/webapps/mobile/],而不是[/usr/local/apache-tomcat-7.0.55/webapps/drc/] --为 'webAppRootKey' context-param 选择一个唯一值在你的web.xml中

解决方法

为后来加载的项目设置新的’webAppRootKey’值,修改项目的web.xml添加如下内容:

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>drc.root</param-value>
</context-param>

在这里插入图片描述
重启tomcat,问题解决。

问题分析

可以理解为tomcat部署的多个项目都使用log4j,如果在项目的web.xml中没有定义webAppRootKey参数,那么她的缺省值就是"webapp.root",就我的这个问题而言,可以理解为“webapp.root”这个key已经指向了项目mobile,不能再指向项目drc了。
所以解决办法就是,在项目的web.xml里面声明 webAppRootKey。

参考链接

1.Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files!
2.WebApproot in Spring

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值