File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes How to manage configuration parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to manage configuration parameters" Watch "How to manage configuration parameters" New topic

How to manage configuration parameters

Olivier Scalbert

Joined: May 07, 2004
Posts: 25
Hi all,

We are writing a JSF web app + some session beans. The jars and wars are packaged inside an ear file.
In this application, they are some configuration parameters that will perhaps change in the future, as directories locations, mail addresses, etc, ...
I do not want to hard-code theses values. I want to put them in a property file or something like that, but outside the ear file, in order to avoid rebuild it in case of change. Is it the good approach ? Are they any other options ?
We are using glassfish.


Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Store the configuration parameters in a relational database.
Olivier Scalbert

Joined: May 07, 2004
Posts: 25
Thanks, that is a good idea !

But in case I have less then 10 parameters, is not it a little bit too overkill? But then what can be another alternative ?

Chandu Cheruku

Joined: Feb 20, 2009
Posts: 1
If you move resources outside your application, it could be very hard to maintain in future.

Other approaches -

1. DB is a very good option.
2. If you dont want to go with DB, write a thread which will reload your properties from your configuration file every n seconds.
3. You can set your configuration details as custom properties on your server container.

Hope this helps.
Reza Rahman
Ranch Hand

Joined: Feb 01, 2005
Posts: 580

Another option is EJB environment entries that are in the XML DD (ejb-jar.xml).


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
jQuery in Action, 3rd edition
subject: How to manage configuration parameters
It's not a secret anymore!