users@glassfish.java.net

NameNotFound exception - makes no sense ?!

From: Mon Cab <futon33_at_yahoo.com>
Date: Mon, 31 Mar 2008 23:07:57 -0700 (PDT)

This is wierd

I have exacly the same code in two different classes, in the same
package, each getting the same JNDI resource, as follows:

Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
DataSource ds = (DataSource)initContext.lookup("jdbc/myDatasource");
Connection con = ds.getConnection();

The first class is called and gets a connection, with no problem, then
the second class, which uses exaclty the same code to get the
connection gets:

No object bound to name java:comp/env/jdbc/myDatasource

exception.

What is going on here?



      ____________________________________________________________________________________
Special deal for Yahoo! users & friends - No Cost. Get a month of Blockbuster Total Access now
http://tc.deals.yahoo.com/tc/blockbuster/text3.com