weblogic部署專案:Cannot set web app root system property when WAR file is not expanded
阿新 • • 發佈:2019-02-20
昨天專案 以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
網上很多解決辦法,說是 log4j 的配置問題,但是怎麼搞都不行!
最後檢視原始碼,發現其實主要問題是 : servletContext.getRealPath函式為空
然後就根據這個去查 ,發現果然是weblogic的問題;
解決辦法:
在web-inf 下面 加 weblogic.xml
- <?xmlversion="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>
然後問題就解決了。