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添加如下内容:


webAppRootKey
drc.root

Choose unique values for the 'webAppRootKey' context-param in your web.xml files!_第1张图片
重启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

你可能感兴趣的