一個tomcat下有多個應用時 多個Context啓動衝突的問題解決

在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,問題解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章