Advanced Configuration of the Spring MVC Framework
Subject:   Why not use jndi?
Date:   2006-03-24 06:29:50
From:   mdebruijn
Why not use the naming server for the environment specific settings?

I've moved the environment specific settings from the applicationContext.xml file to the naming server.
applicationContext.xml example:

<bean id="myService" class="nl.novumsoftware.MyService">
<property name=”url”>
<bean class=”org.springframework.jndi.JndiObjectFactoryBean”>
<property name=”jndiName”>

Example for the naming server in Tomcat:

<Context path="/myweb" ... >
<Environment name="databaseUrl" type="java.lang.String" value="jdbc:oracle:thin:@myHost:1521:myInstance"/>

De ear/war can now be deployed on any machine without modifications. Of course the solution only works for application server managed applications.

Martijn de Bruijn