I have a war file packaged within an ear file. When I try to read a property file in a servlet using ResourceBundle, I get an exception as the property file cannot be found. However, when i deploy the same war alone (w/o packaging it as ear), the war classloader can find the property file and load properties. The property file is placed under WEB-INF/classes folder. And I am using weblogic 7.0.2 app server.
Why can't ear classloader find this file?
what can i do to solve this problem? Can anybody help please?
Now, do i have to set some class path or lib path in the appliocations.xml in the ear so ear classloader can find it? Or is there any other way out?
Originally posted by David O'Meara:
Does the EAR need to load the properties? If only the WAR needs them then leave the WAR ClassLoader loading the classes. There are ways to get the EAR assing the WAR ClassLoader and thereby making the properties available at the EAR level, but better not to if you don't have to.
thanks for the reply David. however, i am still not clear.
The war needs the property file and not ear. The file is at WAR level (web-inf/classes directory). and it is not needed to access it at ear level. Now, i dont know, which classloader fails to access it when i package the war into an ear.
You may find that the problem was in the way you were trying to specify a ClassLoader. Does this sound possible, or am I on the wrong track?
i was able to find the reason, just wanted to share it..
as mentioned in J2EE API Specification, the function
will fail and return null when the resource is inside a war file...
so thatz why its failing in my case....
so i tried using
getServletContext().getResource() this has a new problem..
each time.. the application is access the WLS server extracts the ear to the wldonotdelete folder and creates folder each time the server is started and when the application is accessed first time.
so i cant give
because... when this xml is extracted.. its named as eosXXXXX.xml , where this XXXXX is some random number.. each time..
so is there anyother solution ??