Could you try changing
DataSource ds = (DataSource)initContext.lookup("jdbc/myDatasource");
to
DataSource ds = (DataSource)envContext.lookup("jdbc/myDatasource");
and check whether it works ?
Thanks,
-Jagadish
On Mon, 2008-03-31 at 23:07 -0700, Mon Cab wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>