-
1. Re: binding to local name space at startup
waynebaylor Sep 14, 2007 10:09 AM (in response to lent)do you want to bind to the ENC (java:comp/env/jdbc/...) or to the JVM namespace (java:/...)?
-
2. Re: binding to local name space at startup
lent Sep 14, 2007 12:27 PM (in response to lent)I want to bind to the ENC, i.e. the space from which EJBs typically look up datasources.
Thanks,
Len -
3. Re: binding to local name space at startup
waynebaylor Sep 14, 2007 1:43 PM (in response to lent)you can do two things:
@Resource private DataSource ds;
orejb-jar.xml: <resource-ref> <description>DataSource</description> <res-ref-name>jdbc/MyDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> jboss.xml: <resource-ref> <res-ref-name>jdbc/MyDS</res-ref-name> <jndi-name>java:/MyDS</jndi-name> </resource-ref> your EJB code: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MyDS");
-
4. Re: binding to local name space at startup
lent Sep 14, 2007 3:19 PM (in response to lent)Wayne, thanks for your response. Actually, I want to bind to java:/ namespace, which is where it looks like data sources configured using *-ds.xml files wind up. I can't configure it in a ds.xml file because it is a custom data source.
Thanks,
Len -
5. Re: binding to local name space at startup
lent Sep 14, 2007 7:18 PM (in response to lent)I looked at the JNDI View in jmx-console and I'm finding that I am able to bind to the java:/ namespace from the jboss-service.xml (using JNDIBindingServiceMgr mbean). But I guess I'm approaching this the wrong way since I am binding the custom data source object under the right jndi name thinking this was all that is required but in fact it also needs to be recognized as a DataSourceBinding service in order for the dependency from my EJB to the data source (in the persistence-unit definition) to be resolved.
Len