users@glassfish.java.net

Programmatic Access to GF JDBC resource

From: jbsmathers <jbsmathers_at_gmail.com>
Date: Thu, 8 Oct 2009 20:35:54 -0700 (PDT)

I need to programmatically access a JNDI resource already configured on my
gfv2 app server, from code inside a session bean or helper class deployed on
the server.

I see my JDBC resource from the app server console. I can create an initial
context inside a session bean OK, but the context.lookup() throws
javax.naming.NameNotFoundException. (Even though I see the JNDI resource is
there by looking in the app server admin console.)

Is this because I have not defined the resource in an ejb-jar.xml to be
deployed with my application, -is that required for JNDI resources
configured on the server like my JDBC datasource?

Even if it is required, I can not use deployment descriptors, because then I
would have to reconfigure them and redeploy my application to make use of a
any newly JDBC connection configured on the server.

(My requirement is that I can add a JDBC connection to the app server, and
then configure my application during runtime to use it.

Note that this also prevents me from relying on using the newer JEE resource
injection, as resource injection requires a fixed resource name. (Something
I hope JEE will try to get away from).

Am I making this harder than it is? I hope so, can anyone help?

-- 
View this message in context: http://www.nabble.com/Programmatic-Access-to-GF-JDBC-resource-tp25815014p25815014.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.