4.2报错:Log4jConfigListener:cannot set web app root system property when WAR file is not expanded。
解决办法:这个问题是获取log4j的根路径出现了问题,weblogic中获取根路径和tomcat等服务器稍有不同。修改方法:
web.xml 中与log4j有关的地方:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:properties/log4j.properties</param-value>
</context-param>
public static void setWebAppRootSystemProperty(ServletContext
servletContext) throws IllegalStateException
{
Assert.notNull(servletContext, "ServletContext must not be
null");
String root = System.getProperty("config.dir");
if (root == null) {
throw new IllegalStateException("Cannot set web app root system
property when WAR file is not expanded");
}
String param = servletContext.getInitParameter("webAppRootKey");
String key = param != null ? param : "webapp.root";
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!");
}
System.setProperty(key, root);
servletContext.log("Set web app root system property: '" + key +
"' = [" + root + "]");
}