將兩個相同內容的項目部署在同一個tomcat下,只進行項目名不同情況下:兩個項目總是只有一個可以啟動成功
查看日志信息:
catalina.2016-12-06.log: The web application [/yushen-staff] appears to have started a thread named [DefaultQuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
查看當前localhost中的日志信息:
localhost.2016-12-06.log:java.lang.IllegalStateException: Web app root system property already set to different value: 'audit_staff.root' = [/home/ap/tomcat/tomcat/apache-tomcat-7.0.65/webapps2/yushen-staff/] instead of [/home/ap/tomcat/tomcat/apache-tomcat-7.0.65/webapps/audit-staff/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
原因總結:
webAppRootKey是在Java web項目的web.xml配置文件中表示項目的唯一標示,在Eclipse調試Web項目時,項目的路徑是一個臨時路徑,不在真正的路徑下,
可以通過log4j日志的方式打印出屬性值,來看看臨時項目路徑在哪里,可以用System.getProperty("web.sample.root");
如果web.xm 內沒有設置webAppRootKey項,是為默認設置,那么webAppRootKey就是缺省的"webapp.root"。
所以在web.xml中調整webAppRootKey的值不同(如日志中使用的也需要調整,並且注意日志的路徑與名稱也要進行調整)
<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <context-param> <param-name>webAppRootKey</param-name> <param-value>app.root</param-value> </context-param> <context-param>
注意:如果直接刪除部署信息也會出現 memory leak
The web application [/yushen-staff] appears to have started a thread named [DefaultQuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak.