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
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
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 ...
ReplyDeleteHi, I couldnt find an option "archived real path" in weblogic 9.2
ReplyDeleteAny help pls
Kinetic watches are considered as great investment and energy-saving gadgets, but the solar-powered models can easily compete with them.
ReplyDeleteBut people are more interested in discussing the three newly-released Maurice Lacroix Pontos
D. Dress watches are kept small, sleek and delicate to better emphasize the length of your arm and to compliment delicate dress styles
and fabrics.
my website http://www.sevilcanasansor.com/index.php?do=/blog/103048/an-analysis-of-effortless-watches-advice/add-comment/
Therefore parents are advised to purchase only bedding
ReplyDeletethat is totally suitable for they bed they choose.
And enjoy your new baby, your whole life has just changed.
Browse through their listing for the one you are looking for.
Here is my website; round crib - -
This comment has been removed by the author.
ReplyDeletebrother can give me solution in apache tomcat 7.0
ReplyDeleteThank you so much!!! working fine
ReplyDeleteRellay Nice Post.It also worked for me after updating Weblogic.xml
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethanks man, this saved us from a lot of hustle.
ReplyDeleteI have got a quite silimilar but different issu.. please help me out...
ReplyDeleteOn opening the browser the reports shows as expected but once we logout (without closing the browser) the above discussed error shows up
The 2nd option worked like a charm. Thank you!
ReplyDeletethanks.
ReplyDeleteBy the way, if you need to get a FileInputStream - there is a way:
getResourceAsStream()
for example from servlet:
request.getSession().getServletContext().getResourceAsStream("images/some_image.png")
thanks, it helper
ReplyDeletethanks!. It was useful!!
ReplyDeleteThanks. Really useful
ReplyDeleteThanks. Really useful
ReplyDeleteThank you for disclosing 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 and solutions.
ReplyDeleteThe Lucidtechsystems providing quality weblogic training in hyderabad through clasroom and online along with Build and release training to students world wide.
Thank you!
ReplyDeleteGreat and nice information you have shared.Thanks for sharing.
ReplyDeleteweblogic administrator training
Thank you. Its work.
ReplyDeletesupreme outlet
ReplyDeletegoyard wallet
goyard bags
golden goose outlet
adidas yeezy
golden goose
balenciaga shoes
golden goose
golden goose sale
supreme clothing
ReplyDeleteI am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.I want to share about weblogic administration .
golden goose black friday
ReplyDeletejordan travis scott
bape shoes
bape outlet
golden goose outlet
some day in 2024, i came here to say "You saved my life! Thank you!"
ReplyDelete