I am probably missing something very obvious but for the life of me I cannot find any information regarding this. When you specify a JndiObjectFactoryBean, you specify the jndiName but where does it pick up which JNDI provider it is using?
I am probably missing something very obvious but for the life of me I cannot find any information regarding this. When you specify a JndiObjectFactoryBean, you specify the jndiName but where does it pick up which JNDI provider it is using?
JndiObjectFactoryBean looks up objects using the default JNDI environment used by your container (Tomcat, Jboss, ...).
It works the same way as if you were looking up a datasource registered in tomcat from a servlet you:
It is possible to override the default settings using the property environment of JndiObjectFactoryBean. environment is of type java.util.Properties.Code://lookup using default settings InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup (path);
Thanks for that - is it possible to pass the environment properties in via the application context or bean factory? I have not been able to locate any examples of this or work out what the paramterisation would be.
Thanks in Advance.
Code:<property name="environment"> <props> <prop key="foo">bar</prop> </props> </property>
Absolutely,
I am sorry if i was not enough clear in my first relpy.Code:<bean name="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:env/comp/jdbc/dataSource</value> </property> <property name="environment"> <props> <prop key="key1">value1</prop> <prop key="key2">value2</prop> <prop key="key3">value3</prop> </props> </property> </bean>
Excellent thanks alot, for some reason I have had a complete blind spot over this. Much appreciated.