Mapping of logical resource-name to absolute jndi-name for data source

Hi,

I am using SJS AS 8.1. I do a lookup for datasource using logical name specified in ejb-jar.xml using resource-ref element as below :

<resource-ref>

<res-ref-name>jdbc/db-resource</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

<res-sharing-scope>Shareable</res-sharing-scope>

</resource-ref>

jdbc/db-resource is mapped to absolute jndi name 'jdbc/jndi-db-resource' in sun-ejb-jar.xml as below :

<resource-ref>

<res-ref-name>jdbc/db-resource</res-ref-name>

<jndi-name>jdbc/jndi-db-resource</jndi-name>

</resource-ref>

I have configued data source using admin GUI with JNDI name jdbc/jndi-db-resource. When I do a look up of datasource as below :

initalContext.lookup("jdbc/db-resource");

from the EJB I get NameNotFoundException. How do I configure logical datasource name using admin GUI ?

Thanks,

Manisha.

[1085 byte] By [ManishaUmbarje] at [2007-11-26 8:55:03]
# 1

Hi Manisha,

When doing a lookup of standard j2ee connection factories like jms or jdbc "java:comp/env" need to be prefixed.

initalContext.lookup("jdbc/db-resource");

need to be

initalContext.lookup("java:comp/env/jdbc/db-resource");

For more information :

http://docs.sun.com/source/819-0079/dgjndi.html#wp24616

Thanks,

-Jagadish

JagadishPrasath at 2007-7-6 22:52:05 > top of Java-index,Application & Integration Servers,Application Servers...
# 2
Thanks Jagadish. That works !Thanks again,Manisha.
ManishaUmbarje at 2007-7-6 22:52:05 > top of Java-index,Application & Integration Servers,Application Servers...