SEVERE: Error listenerStart(listener啓動失敗)

兩個app單獨啓動就ok,同時部署就severe了,listener啓動失敗

原因是加了spring的log4j監聽器
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

Log4jConfigListener的contextInitialized方法最終會調用WebUtils.setWebAppRootSystemProperty來設置webapp.root,如果root已經存在就會拋出異常,代碼如下:
String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
String oldValue = System.getProperty(key);
if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) {
throw new IllegalStateException(
“Web app root system property already set to different value: ‘” +
key + “‘ = [" + oldValue + "] instead of [" + root + "] – ” +
“Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files!”);
}

解決辦法從上面代碼也就能猜到,就是在web.xml中爲每個app設置各自的WEB_APP_ROOT_KEY_PARAM,如下
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>mmcroot</param-value>
</context-param>

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