JNDI lookup in Tomcat and JBoss
On specifying a Datasource's JNDI name as 'jdbc/myDatasource', Tomcat (6) binds that as 'java:/comp/env/jdbc/myDatasource' while JBoss (5) binds as 'java:/jdbc/myDatasource'. When I try to do lookup using Spring like below-Code:
lt;jee:jndi-lookup id=quot;dataSourcequot; jndi-name=quot;jdbc/myDatasourcequot; resource-ref=quot;truequot;/gt;
it works well with Tomcat but fails on JBoss. The JNDI prefix is hard coded in Spring to 'java:comp/env/' as shown below-Code:
public abstract class JndiLocatorSupport extends JndiAccessor {
/** JNDI prefix used in a J2EE container */
public static final String CONTAINER_PREFIX = quot;java:comp/env/quot;;
So it is obvious that it will fail on JBoss. Is there any workaround available to make the same Spring configuration work on both Tomcat and JBoss?
I came up with a solution, which is explained in detail at 2008/12/j...oss-using.html. If someone has a better solution, I would like to know that. |