Discussion:
Accessing Properties File external to ear/war deployed to Websphere
(too old to reply)
Jim Solderitsch
2009-10-08 16:21:12 UTC
Permalink
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 mySettings.properties) 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 mySettings.properties 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
2009-10-08 16:35:47 UTC
Permalink
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.

Jim
c***@fr.ibm.com
2009-10-08 16:57:32 UTC
Permalink
Shared library is certainly one option.
See http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.base.doc/info/aes/ae/tcws_sharedlib_create.html 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
2009-10-08 17:26:19 UTC
Permalink
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.

Jim
c***@fr.ibm.com
2009-10-08 18:42:17 UTC
Permalink
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 7.0.0.0 [ND 7.0.0.0 r0835.03] running with process name zproNode06Cell\zproNode06\server1 and process id 6391
Host Operating System is Linux, version 2.6.16.46-0.12-xen
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
ws.ext.dirs=/local/IBM/WebSphere70x64/java/lib:/local/IBM/WebSphere70x64/profiles/main/classes:/local/IBM/WebSphere70x64/classes:/local/IBM/WebSphere70x64/lib:/local/IBM/WebSphere70x64/installedChannels:/local/IBM/WebSphere70x64/lib/ext:/local/IBM/WebSphere70x64/web/help:/local/IBM/WebSphere70x64/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime

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 manageprofiles.sh script) will backup/restore the content of the classes or the shared library directory. These will have to be handled separately.
Jim Solderitsch
2009-10-08 21:00:39 UTC
Permalink
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/com.ibm.etools.ejbdeploy/runtime
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.
VM
2017-01-31 13:19:28 UTC
Permalink
Would you care to share your test results here. Might be useful for the community.

Thanks,

VM
Post by Jim Solderitsch
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.
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/com.ibm.etools.ejbdeploy/runtime
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.
VM
2017-01-31 13:19:40 UTC
Permalink
Would you care to share your test results here. Might be useful for the community.

Thanks,

VM
Post by Jim Solderitsch
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.
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/com.ibm.etools.ejbdeploy/runtime
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.
VM
2017-01-31 13:19:44 UTC
Permalink
Would you care to share your test results here. Might be useful for the community.

Thanks,

VM
Post by Jim Solderitsch
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.
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/com.ibm.etools.ejbdeploy/runtime
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.
Loading...