users@glassfish.java.net

Querying JNDI resource on GlassFish always returns null

From: <forums_at_java.net>
Date: Mon, 16 May 2011 08:56:26 -0500 (CDT)

How you doing guys, I had and old Servlet app running on Tomcat that I was
trying to move to GlassFish v3, so I downloaded it, installed and the app
kicks nicely at first glance but it's not really operational because my code
relies on a database connection pool (JNDI) that I had on Tomcat, I followed
the steps to create a connection Pool on GlassFish and on the admin portal it
worked great, I was able to ping the database successfully, now I'm missing
the code that needs to be changed in order to query that JNDI resource,
everything that I've tried so far returned NULL, can you guys help me out?

Thank you

*I have the following JDBC Connection Pool setup on GlassFish:*

  *  microsoft_jtds_pool (Ping worked successfully)

*_____________________________________________
I have the following JDBC Resource setup on GlassFish:*

  * dataConn (Pool Name: microsoft_jtds_pool)

*_____________________________________________
I ran the command line "list-jndi-entries" and GlassFish returned:*

asadmin> list-jndi-entries
/dataConn: org.glassfish.javaee.services.ResourceProxy
/java:global: com.sun.enterprise.naming.impl.TransientContext
UserTransaction:
com.sun.enterprise.transaction.TransactionNamingProxy$UserTransactionProxy
com.sun.enterprise.container.common.spi.util.InjectionManager:
com.sun.enterprise.container.common.impl.util.InjectionManagerImpl
ejb: com.sun.enterprise.naming.impl.TransientContext
jdbc: com.sun.enterprise.naming.impl.TransientContext

*_____________________________________________*
 

*I've been trying the following code on a JSP file:*

<%
   Context initCtx = new InitialContext();
   Context envCtx = (Context) initCtx.lookup("java:comp/env");
   envCtx.lookup("dataConn");
  %>

*_____________________________________________*
 

*The result is always:*

*Exception Details: *javax.naming.NameNotFoundException 
  No object bound to name java:comp/env/dataConn


--
[Message sent by forum member 'theplague']
View Post: http://forums.java.net/node/802621