I have an action class\servlet that references a .properties file. I am running the app on a websphere server off of my local pc.
The only way I can get the server to see the properties file is to give it a full path ie: System.setProperty("OSS_CLIENT_CONFIGURATION","C:\\Documents and Settings\\IBM\\rationalsdp6.0\\APworkspace\\APElapsedTime\\WebContent\\WEB-INF\\source\\com\\corp\\elapsedtimeosds\\resources\\OSSclient.properties");
I tried this but got a could not find error: System.setProperty("OSS_CLIENT_CONFIGURATION","..\\WebContent\\WEB-INF\\source\\com\\corp\\elapsedtimeosds\\resources\\OSSclient.properties");
Obviously I can't use a local path to the properties file when I deploy the app. Any suggestions on how to setup a properties file so that a servlet can read it off of the server?
posted 11 years ago
actually looking around on the forums, I found this:
Firstly, if you get a reference to the System properties and update them, then the System properties should be updated. You shouldn't need to write them back.
Starting from first principles though, should you be doing this via a properties file, or should you be setting the System properties on the command line using the JVM -D arguments?
Thirdly, you could read the file from into a new properties instance, then iterate the values and use System.setProperty(...)
posted 11 years ago
Thanks David. As always, you are correct on all of those points.
The last problem I am having is, I have an object that needs a properties file setup as a System property. For example, System.setProperty("CLIENT_CONFIGURATION","C:\\OSSclient.properties"); This works fine, but obviously isn't portable. I have this properties file in the WebContent directory but I get a file not found error when the object referecnces the property. I tried something like this: System.setProperty("CLIENT_CONFIGURATION","OSSclient.properties"); but that didn't work. Any ideas?
Also, I am running this off of a WebSphere server, but I don't think that should matter too much.