Apr
22
2010
Shared/Global JNDI Environment Variables
I encountered a situation where I needed some simple Strings accessible to all my applications in glassfish. If you need environment variables in a single web app, it’s as easy as editing web.xml. However I’ve separated my application into several web and ejb modules for manageability concerns, thus I needed to set variables in the application server. I decided to create a Factory that returns a Hashtable of properties one can set in the application server. For this I run on Glassfish 2.1.1; I have not tested it with any other container though I do not see why it wouldn’t work.
Required Files
First the files. You’ll need the following jar. Save it in your application server’s lib directory. On my machine that is C:\sun\appserver\lib.
There are two classes in this jar:
com.ebleenterprises.naming.HashtableFactory com.ebleenterprises.naming.StringFactory