1. 程式人生 > >weblogic部署專案:Cannot set web app root system property when WAR file is not expanded

weblogic部署專案:Cannot set web app root system property when WAR file is not expanded

昨天專案 以2種方式進行跑,一種是 war包,一種是 資料夾的形式!

tomcat 下面2種方式都沒問題。

weblogic下面 war包的形式進行部署的話 報如下錯誤:

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

網上很多解決辦法,說是 log4j 的配置問題,但是怎麼搞都不行!

最後檢視原始碼,發現其實主要問題是 : servletContext.getRealPath函式為空

然後就根據這個去查 ,發現果然是weblogic的問題;

解決辦法:

在web-inf 下面 加  weblogic.xml 

  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <!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">
  3. <weblogic-web-app>
  4.   <container-descriptor>
  5.     <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
  6.   </container-descriptor>
  7. </weblogic-web-app>

然後問題就解決了。