`

【转】Weblogic上servletContext.getRealPath函数返回Null

阅读更多
------------------------------------以下为原文-------------------------------------

一、问题描述:

1.当应用以WAR的形式布署到WebLogic时,代码中的servletContext.getRealPath函数为空。(不包含以目录形式发布的情况)

2.发布或启动应用时出现如下异常信息:

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

二、涉及版本:

WebLogic的各版本都可能有此问题。

三、问题原因:

WebLogic在发布WAR格式的应用时,servletContext.getRealPath的默认实现仅返回Null。

四、解决方案:

在应用的WEB-INF/weblogic.xml文件中(如没有请自行创建),<container-descriptor>元素内加入配置片断<show-archived-real-path-enabled>true</show-archived-real-path-enabled>。

即:
<?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>


-------------------------------------------------------------------------------

碰到同样问题,该入weblogic.xml后,servletContext.getRealPath取值正常。

原文地址:http://wiki.bsdn.org/pages/viewpage.action?pageId=3440713
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics