Hello,
We have a properties file that needs to be outside our war/jars in order for client to be able to change it.
Overall structure of our application is as follows:
one Utility.jar which has our utility classes, daos, dtos
one MyEjb.jar - with ejbs - which have dependency on Utility.jar
one MyWeb.was - which also have dependency on Utility.jar
and offcource the MyApp.ear
properties file is going to be read by LookUp.java (actually class) in Utility.jar - it basically reads the property file and loads the parameters. Other classes in Utility.jar will be calling this class to get the property they need.
property file is just a list of name=value pairs and we are just using file io to read the file (not Load property or anything like that)
Now, my question is where do I put this property file on a Linux system so that my class in Utility.jar can read it?
I have tried several approaches (I am using WAS 5.1 running on Linux) - putting it in /usr/lib and adding that to CLASSPATH and PATH, putting it where the Utility.jar is, putting it in AppServer/property, putting it in AppServer/lib, creating a Shared library (pointing to /usr/lib where property file is) on WAS and mapping it to the application,putting it under ear root and adding that path to manifest path under each module,,,,,,,,,,,,,,,,
but nothing seems to work :(
am I missing something?????????????? any suggestions?????
Thanks,
P.I.
It is such a simple scheme
-
property file location (7 messages)
- Posted by: P I
- Posted on: June 30 2005 23:07 EDT
Threaded Messages (7)
- property file location by Fredrik Rubensson on July 01 2005 03:23 EDT
- property file location by Einar Valen on July 01 2005 05:28 EDT
- property file location by P I on July 01 2005 08:55 EDT
- Put file in CLASSPATH by Preetam Palwe on July 05 2005 05:46 EDT
- property file location by sanjay manchiganti on July 07 2005 16:37 EDT
- Re: property file location by Diana Ross on March 28 2007 14:54 EDT
- Re: property file location by Preetam Palwe on April 28 2007 07:09 EDT
-
property file location[ Go to top ]
- Posted by: Fredrik Rubensson
- Posted on: July 01 2005 03:23 EDT
- in response to P I
You are not supposed to read files from the file system but it can be done anyway. One way is to send the path to the property file as a system property when starting the app server, something like this:
-Dsome.name=/path/to/the.properties
Have done that succesfully with WebLogic. -
property file location[ Go to top ]
- Posted by: Einar Valen
- Posted on: July 01 2005 05:28 EDT
- in response to Fredrik Rubensson
This approach works on WebSphere to. Provided your properties are loaded as a bundle, you may as an alternative add it's path to the app-server's class path. -
property file location[ Go to top ]
- Posted by: P I
- Posted on: July 01 2005 08:55 EDT
- in response to Fredrik Rubensson
You are not supposed to read files from the file system but it can be done anyway. One way is to send the path to the property file as a system property when starting the app server, something like this:-Dsome.name=/path/to/the.properties Have done that succesfully with WebLogic.
how do I do this? Do I alter startServer.sh script to add this at the end?
Also, does the .property file have to be loaded as resource bundle or a simple text file with name=value pair should work with this approach? I am using WAS 51. on linux
Thanks,
P.I. -
Put file in CLASSPATH[ Go to top ]
- Posted by: Preetam Palwe
- Posted on: July 05 2005 05:46 EDT
- in response to P I
Put file in CLASSPATH and use
ClassLoader.getSystemResource("filename")
.. best way is put file in ur utility.jar and use
ClassLoader.getSystemResource("filepathinjar/filename") -
property file location[ Go to top ]
- Posted by: sanjay manchiganti
- Posted on: July 07 2005 16:37 EDT
- in response to P I
HI...
I didn't see this post before I posted somethign that is very similar to your requirement.
One way I solved this(but is not extensible) is to put it in your META-INF of the Utility.jar and use Lookup.class.getClassLoader().getResource(<properties_file>). But it is not really extensible as different EAR files that use this jar has different requiremnts for properties.
Ideally, it should be at EAR level thereby giving maximum extensibility. But, I haven't found a way to read it. :) Pls. post if you have any comments.
thanks,
sanjay. -
Re: property file location[ Go to top ]
- Posted by: Diana Ross
- Posted on: March 28 2007 14:54 EDT
- in response to P I
Please let me know the solution to load a ResourceBundle from outside the ear/war/jar. Thanks! -
Re: property file location[ Go to top ]
- Posted by: Preetam Palwe
- Posted on: April 28 2007 07:09 EDT
- in response to Diana Ross
if the properties file is outside ear/war specify its location using vm properties like -Dproperty.file.path=/root/myproperties.properties and access that using Syetm.getProperty("property.file.path");