views:

121

answers:

3

Hello all,

I have a set of EJBs and other Java classes which need to be configured differently based on the system environment in which they are deployed: production, test, or lab. The configuration information includes stuff like URLs and database connection information.

We'd like to deploy the same exact product (EAR file) in each environment, and have the code then figure out where it is and what its configuration should be, without having to reach out to each deployment server in each environment to make changes.

What is the best way to configure all these components in a centralized, reliable, easy-to-maintain fashion?

Thanks for your thoughts.

A: 

How database connection pool information is stored / configured depends on the app server vendor. Put other variable stuff in property files on the classpath.

Paul Croarkin
+2  A: 

The best, IMHO, is to use JNDI entries.

You may have to recode some parts of your application in order to use theses entries instead of plain vars, but with this setup:

  • Configuration is server-independant: each vendor provides its own implementation, but spec is a standard.
  • In a clustered environment, config can be persisted in a cluster-wide JNDI tree (see JBoss)
  • Configuration can be changed thru webadmin without restarting server.
Pierre-Yves Gillier
A: 

If you are deploying the exact same EAR to three different instances of a certain container than you will have to edit the deployment settings as there is no way that the deployment process could have any idea about which one of your three versions you would like to use at a particular deployment.

Deployment settings should go into JNDI entries as Piere-Yves said above.

If I were you, I would have my deployment-script (Ant?) properly populate the JNDI entries depending upon which environment you are deploying to.