Cannot set web app root system property when WAR file is not expanded

昨天项目 以2种方式进行跑,一种是 war包,一种是 文件夹的形式!

tomcat 下面2种方式都没问题。

weblogic下面 war包的形式进行部署的话 报如下错误:

Caused By: java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded
at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:139)
at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:118)
at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:47)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
Truncated. see log file for complete stacktrace

网上很多解决办法,说是 log4j 的配置问题,但是怎么搞都不行!


最后查看源码,发现其实主要问题是 : servletContext.getRealPath函数为空

然后就根据这个去查 ,发现果然是weblogic的问题;


解决办法:

在web-inf 下面 加  weblogic.xml 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
 
<weblogic-web-app>
  <container-descriptor>
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
  </container-descriptor>
</weblogic-web-app>

然后问题就解决了。

最近又遇到这个问题,发现另外一个新解决办法:

在web.xml 中配置 如下参数:

  <context-param>
    <param-name>log4jExposeWebAppRoot</param-name>
    <param-value>false</param-value>
  </context-param>
不过如果这样做的话 ,那么 log4j的配置文件 只能放在 class 下面 不能放在 web-inf 下面; 
即 不能如此配置:

<!--启动LOG4J-->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>
    <listener>
应该:

<!--启动LOG4J-->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.properties</param-value>
    </context-param>
    <listener>




主要参考: http://wiki.bsdn.org/pages/viewpage.action?pageId=3440713

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值