-
1. Re: Static resource location
frito Dec 8, 2004 6:39 AM (in response to sylobsa)You don't need an absolute path.
If the properties file is located in your archive, it is in your apps class path, too.
Use the ContextClassLoader for loading it. -
2. Re: Static resource location
sylobsa Dec 9, 2004 5:01 AM (in response to sylobsa)Thank for your response.
I don't need absolute path and must use the ContextClassLoader. But can you give me an example on how to use it and get my properties file ?
Regards -
3. Re: Static resource location
frito Dec 9, 2004 5:14 AM (in response to sylobsa)Let's say your property file "myProp.properties" is located at top level in one of your JARs:
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("myProp.properties"); -
4. Re: Static resource location
sylobsa Dec 9, 2004 8:11 AM (in response to sylobsa)
Doesn't work for me.
Here is my configuration :
MyApp.ear
static.war
MyWeb.war
MyEJB.jar
The properties file is in the static.war archive.
The path is : /dir1/dir2/MyFile.properties
The class needing this properties file is located in the MyEJB.jar archive.
I tried :
InputStream is = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(f);
with :
f="/static/dir1/dir2/MyFile.properties"
f="MyFile.properties"
f="/dir1/dir2/MyFile.properties"
The "is" input stream is always null.