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?????
It is such a simple scheme
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:
Have done that succesfully with WebLogic.
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.
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
Put file in CLASSPATH and use
.. best way is put file in ur utility.jar and use
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.
Please let me know the solution to load a ResourceBundle from outside the ear/war/jar.
if the properties file is outside ear/war
specify its location using vm properties like
and access that using Syetm.getProperty("property.file.path");