Mantis - Resin
Viewing Issue Advanced Details
1603 minor always 02-05-07 11:29 05-31-07 14:40
none 3.1.2  
0001603: JNDI lookup with spring
(rep by aadi deshpande)

On Resin 3.022 ( running on a Java 1.5 install on a Solaris 10 Sparc
environment ), I'm encountering a strange error when attempting to look up a
datasource in JNDI via Spring's JNDIObjectFactoryBean.

My database is set up like so :

          <driver type="oracle.jdbc.pool.OracleConnectionPoolDataSource">

In my application context, i have :

       <bean id="dataSource"
               <property name="resourceRef" value="true"/>
                <property name="jndiName" value="jdbc/ds" />

When starting up my application, I get a NameNotFoundException, thrown by
ContextImpl :

[13:49:56.316] WebApp[http://localhost:9000/app] [^] initializing
[13:49:56.345] creating JNDI java: model for
EnvironmentClassLoader$13599389[web-app:http://localhost:9000/app] [^]
http://localhost:9000] [^]
[13:49:56.346] JNDI lookup `java:comp/env/caucho/auth' exception
javax.naming.NameNotFoundException: java:comp/env/caucho/auth
[13:49:56.346] javax.naming.NameNotFoundException: java:comp/env/caucho/auth
[13:49:56.347] WebApp[http://localhost:9000/app] [^] initialized
[13:49:56.348] WebApp[http://localhost:9000/app] [^] starting
[13:49:56.426] real-path / -> /opt/resin/webapps/app/
[13:49:56.428] Set web app root system property: 'webapp.root' =
[13:49:56.449] Initializing Log4J from []
[13:49:58.599] Loading Spring root WebApplicationContext
[13:50:00.316] real-path /WEB-INF/application-context.xml ->
[13:50:03.548] JNDI lookup `java:comp/env/jdbc/ds' ->
[13:50:05.843] JNDI lookup `java:/comp/env/jdbc/ds' exception
javax.naming.NameNotFoundException: java:/comp/env/jdbc/ds

Note that the 'java:comp/env/jdbc/ds' is changed to 'java:/comp/env/jdbc/ds'
( leading slash before 'comp' ).
which causes the lookup to fail.

I've checked the Spring source code and it seems to be making the lookup
fine, generating the correct name.

Moreover, when i specify the jndi-name of the datasource to be
"java:/comp/env/jdbc/ds" and the jndiName in my application context file to
be 'java:/comp/env/jdbc/ds", then it works fine.

However, any combination of specifying "jdbc/ds" or "java:comp/env/jdbc/ds"
as my jndi-name and the explicit path ( "java:comp/env/jdbc/ds" ) or the
base path ( "jdbc/ds" ) with resourceRef=true, it fails with the
abovementioned error.

the normal convention of specifying "jdbc/ds" with resourceRef=true or the
full name "java:comp/env/jdbc/ds" in jndiName works just fine with other
containers that I've attempted this test on, including Tomcat and Jetty.

Have I encountered a bug or am I too obtuse to be witness to my own

Thanks for any help you can provide,

05-31-07 14:40