Another weird behavior from weblogic when webapp is deployed as WAR. ServletContext.getRealPath() returns null when deployed as WAR but it works ok when deployed as exploded. There are two ways we can fix this issue when you still want to deploy as WAR but would like to get over with this issue:
1. Go to server admin console->Domain-> Web applications. Click the checkbox of Archived Real Path Enabled. This should make an entry into domain config.xml as below.
<web-app-container>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</web-app-container>
2. Second option is at webapp level by updating weblogic.xml as below:
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
The value of <show-archived-real-path-enabled> set in the web app has precedence over the value set at the domain level. The default value of this property is false.
Subscribe to:
Post Comments (Atom)

very useful. it worked well
ReplyDeleteVery much useful tip . Thanks a ton !!!!
ReplyDeleteI am working on developing a servlet in JDeveloper 11g which needs to "know" the physical path to the Web Content folder. I kept getting "null" when calling ServletContext.getRealPath() and was totally baffled. Following your second option was the "best fit" solution for me and worked like a charm. Thanks so much for posting this!
ReplyDeleteYou saved my life!!! :)
ReplyDeleteExcellent Help from this blog really thankfull from the bottom of my heart SIR................
ReplyDeleteThanks. I started to feel uneasy, because my stuff was not working on the new weblogic.
ReplyDeleteThanks a lot! It took me whole day to find solution.
ReplyDeletethank you very much
ReplyDeleteThanks...
ReplyDeleteAwesome, thanks a lot. Worked for me.
ReplyDeleteUsed the second option and worked great!! Thank you!!
ReplyDeleteThis is my first time to post here. Thank you so much for your help. The first option worked for me very well but I want to use the second one. May you please tell me where I can find the weblogic.xml? I searched for it in my app but couldn't find it.
ReplyDeleteThanks
weblogic.xml could be found in yourWebApp/WEB_INF directory.
ReplyDeleteThank you so much..
ReplyDeleteThank you very much.
ReplyDeleteditto
ReplyDeletegreat! thanks
ReplyDeleteGreat man thanks for this :)
ReplyDeleteThank you for the great help
ReplyDeleteGreat ..!I used the second option and it works very well..
ReplyDeleteThank You so much for posting this!
its only for weblogic 10.x or higer in the version 9.2 not work
ReplyDeleteThanks a lot It worked for me.
ReplyDeleteit's really helpful for us thanks a lot
ReplyDeleteHey..Nice tip...But still the the classes under the war/waeb-inf/classes is empty after installing the app..Calling realPath(/WEB-INF/classes/) gives me the path properly, but under the classes nothing is there..Any idea?
ReplyDeleteYou are the man dude!! Second option works nice! Thnx very much!
ReplyDeleteThanks ,really it's help me a lot... :)
ReplyDeleteLooks like this will be useful. Well my problem is similar but for tomcat 7. Will anyone know, how to get rid of getRealpath("/") returning null.
ReplyDeleteyou can see your class in a jar file named _wl_cls_gen.jar. this is created by server. you can see this jar in jar folder in your web-inf.
DeleteThanks a lot. It worked for me as well with the second option
ReplyDeleteHi i tried making the changes in weblogic.xml but true does not show up at all. :( Any suggestions ??
ReplyDelete*show-archived-real-path doesnt show up i weblgic.xml
DeleteThis comment has been removed by the author.
ReplyDeleteAwesome!!!! it worked, however my js were not getting loaded and I had to add mime mapping in Web.xml for my js. Well..!! allz well that ends well...
ReplyDeletethanks Ananth..
I am not sure why is it not working for me, can some please help me, when i updated option1 in config.xml my weblogic console is shutting down and to try option2 i am not finding weblogic.xml in application directory, Please please some one help me
ReplyDeletethanks man
ReplyDeletethanku so much!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks Ananth, the second solution did not work , but the first one did , many thanks ...
ReplyDelete08Ct, the VG cutting technique would ensure crafts concentration.
ReplyDeleteFresh water cultured pearls turn up in a
wider range of colors and shapes than their saltwater counterparts.
There is no need to make it fancy, just make it delicious and abundant.
Here is my website; http://www.nataledonna.com/bessboyle