Accessing Properties File external to ear/war deployed to Websphere

Skip to first unread message

Jim Solderitsch

Oct 8, 2009, 12:21:12 PM10/8/09
I am coming from JBoss (and Oracle App Server 10g) where it is possible to place a properties file external to the application ear or war but is picked up just like it was included inside it (e.g. in WEB_INF/classes).

In JBoss, I can place the file ( call it in the conf folder inside of server/default. This folder is at the same level as the deploy folder where the actual war and ear files are located.

For Oracle 10g, this file needed to located in the applib folder and this folder is at the same level as the applications folder where the actual ear and war files are located.

Is there a location for WAS 7 where I can place this properties file so that my access method can find it. I know I can package it with the ear itself, but we like the properties file to be outside of the deployable ear so that it can be adjusted to handle external dependencies.

We have a PropertyManagerFactory where we generate an instance and from this instance we retrieve properties like this:

PropertyManagerFactory.getInstance().getValue(LOGO_LOCATION_PROPERTY, ".");

LOGO_LOCATION_PROPERTY is defined in and the value there may be different depending on where we deploy the ear.

Any answers to my situation will be much appreciated.

Jim Solderitsch

Oct 8, 2009, 12:35:47 PM10/8/09
I did a little searching in the forum and perhaps the concept of Shared Libraries applies here. I don't need to share code resources but property resources but these are accessed via the class path anyway.

Can anyone advise if this is indeed the best way to proceed?

A link to the IBM WAS 7 docs to explain how to accomplish this?

Can the definition of such a shared library be scripted so I can run a script from the command line, or do I need to use the WAS admin console?

Thanks again.


Oct 8, 2009, 12:57:32 PM10/8/09
Shared library is certainly one option.
See to create the shared library through the WAS admin console. Your property file can then be located in any directory you want accessible from the app server (you specific in the shared library configuration which directory to use).
You then need to configure your J2EE application (war or ear) to use this library (see links from the doc page referenced above).
All that can be scripted using WAS scripting capabilities (but you will need further research to figure out exactly how to do it).

Another option is to create a classes directory directly in the WAS profile (in AppServer/profiles/). Anything (jar, property files, etc) placed in this directory is automatically in the classpath of all J2EE applications. A little more brutal since it is impacting the "global" classpath of the app server (in the classpath of all apps while with the shared library you can select which app will use it) but this should work as well.

Jim Solderitsch

Oct 8, 2009, 1:26:19 PM10/8/09
Thanks for the idea about creating a classes directory in my WAS profile. This seems more like the idea that Oracle uses with its notion of applib.

I will try that as a first choice to see if that works the way I expect it too. This is a zero configuration solution although global in scope.

To be precise, in my profile I see folders called installableApps, bin, firststeps, etc. If I create a classes folder there as well and drop my properties file in there, it will be accessible?

But the Shared Library approach might be better in the long run.


Oct 8, 2009, 2:42:17 PM10/8/09
Yes, just created the classes directory in the profile and dropping your property file in it should work.
If you look the WAS startup traces (in SystemOut.log) you should see something like that in it:

************ Start Display Current Environment ************
WebSphere Platform [ND r0835.03] running with process name zproNode06Cell\zproNode06\server1 and process id 6391
Host Operating System is Linux, version
Java version = 1.6.0, Java Compiler = j9jit24, Java VM name = IBM J9 VM
was.install.root = /local/IBM/WebSphere70x64
user.install.root = /local/IBM/WebSphere70x64/profiles/main
Java Home = /local/IBM/WebSphere70x64/java/jre

In the ws.ext.dirs (WAS extended classpath directories) you have "/local/IBM/WebSphere70x64/profiles/main/classes" which is this classes directory (in my case, my profile is called "main").

A shared library is definitely "cleaner" but more work is needed to put it in place.

FYI, I do not think that a profile backup/restore (using the script) will backup/restore the content of the classes or the shared library directory. These will have to be handled separately.

Jim Solderitsch

Oct 8, 2009, 5:00:39 PM10/8/09
I added the classes folder to the profiles directory and looked at the log.

I don't see the classes folder in the ws.ext.dirs listing in the startServer.log.

What I see is:

ws.ext.dirs = /opt/IBM/SDP/runtimes/base_v7/java/lib:/opt/IBM/SDP/runtimes/base_v7/classes:/opt/IBM/SDP/runtimes/base_v7/lib:/opt/IBM/SDP/runtimes/base_v7/installedChannels:/opt/IBM/SDP/runtimes/base_v7/lib/ext:/opt/IBM/SDP/runtimes/base_v7/web/help:/opt/IBM/SDP/runtimes/base_v7/deploytool/itp/plugins/
Classpath = /home/jjs/WAS/base_v7/WTE_APPSRV7_FEP1/properties:/opt/IBM/SDP/runtimes/base_v7/properties:/opt/IBM/SDP/runtimes/base_v7/lib/startup.jar:/opt/IBM/SDP/runtimes/base_v7/lib/bootstrap.jar:/opt/IBM/SDP/runtimes/base_v7/lib/lmproxy.jar:/opt/IBM/SDP/runtimes/base_v7/lib/urlprotocols.jar:/opt/IBM/SDP/runtimes/base_v7/java/lib/tools.jar

My profiles location is: /home/jjs/WAS/base_v7/WTE_APPSRV7_FEP1

But I do see that there is a properties entry in the Classpath and that /home/jjs/WAS/base_v7/WTE_APPSRV7_FEP1/properties already exists in my profiles.

So I expect that I can add my properties file there and it should be picked up. I will test that out and post back results.


Jan 31, 2017, 8:19:29 AM1/31/17
Would you care to share your test results here. Might be useful for the community.


Reply all
Reply to author
Message has been deleted
Message has been deleted
0 new messages