Not sure if I could still be of help here, but I was looking to do something similar and created my own custom jnditemplate
Code:
public class CustomJndiTemplate extends JndiTemplate{
protected Context createInitialContext() throws NamingException {
log.info("Lookup environment properties for datasource");
//Create a context to the local naming service
InitialContext ctx = new InitialContext();
String url = ctx.lookup("myprovider.url").toString();
String factory = ctx.lookup("mycontext.factory").toString();
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, factory);
ht.put(Context.PROVIDER_URL, url);
log.info("Creating new initial context for datasource, with url: " + url);
//Create a new initial context with the jndi url for the datasource and return
return new InitialContext(ht);
}
Then, in my context I reference my customJndiTemplate for my datasource:
Code:
<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="customJndiTemplate"/>
<property name="jndiName" value="jndiFor.jdbc"/>
</bean>