tomcat部署相同项目出现memory leak

将两个相同内容的项目部署在同一个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.

posted @ 2016-12-06 17:59  W&L  阅读(1996)  评论(0编辑  收藏  举报