• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB JNDI lookup WAS 4.0

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We are doing a JNDI Lookup in our utility class like this.
Context ctx = new InitialContext();
DataSource ds = ctx.lookup("jdbc/dbSource");
But in the sample code i have seen, the lookup looks like this.
DataSource ds = ctx.lookup("java:comp/env/jdbc/dbSource");
Now,
1. Is there a difference in these two lookups?
2. When we do the second lookup, it throws the naming exception. This might be because for Web Modules -> Resource References name and the jndi names are different. but I am not sure.
Please let me know if you have some inputs.

Thanks & Regards,
Nijeesh.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The top one looks it up from the global JNDI namespace. The second one looks up a name defined in the ejb-jar.xml as being local to that particular EJB (which is bound to a name in the global namespace during deployment). Read Richard Monson-Haefel's EJB book for an explanation of how JNDI works and what the two mean.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic