首页 > 代码库 > Choose unique values for the 'webAppRootKey' context-param in your web.xml files!

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

在Tomcat的server.xml中配置两个context,出现其中一个不能正常启动,交换配置顺序,另一个又不能正常启动,即始终只有第二个配置能启动的情况。如果单独部署,都没有问题。报错大致内容如下:

 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.

起初以为是内存分配不够,但加大了内容配置问题依然。

于是在localhost.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‘ = [/home/web/grows/] instead of [/home/web/mall/] - Choose unique values for the ‘webAppRootKey‘ context-param in your web.xml files!


大意是Log4jConfigListener在获取webapp.root值时,被后一context的值替换掉了,所以要在各个项目的web.xml中配置不同的webAppRootKey值,随即在其中一个web.xml中添加:

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>web.sample.root</param-value>
</context-param>


重启tomcat,问题解决。

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