tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: HELP! JNDI DataSource Name
Date Thu, 09 Oct 2008 07:52:18 GMT

On Sep 19, 2008, at 5:10 PM, rde8026 wrote:

> Object obj1 = new
> javax.naming.InitialContext().lookup("java:openejb/Resource/JTADS");
> I've also tried it like this:
> Properties props = new Properties();
> props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> javax.naming.Context ctx = new javax.naming.InitialContext(props);
> Object obj1 = ctx.lookup("java:openejb/Resource/JTADS");
> I always get this error: NameNotFoundException: Name
> "java:openejb/Resource/JTADS" not found.
> Now the reason I need to understand the correct JNDI name is so I  
> can use it
> as a Hibernate Property (hibernate.connection.datasource).
> I'm using openejb 3.1 SNAPSHOT and Hibernate
> Any ideas?  I'm totally I understand it this should just  
> work...
> Thanks in advance....

If hibernate is getting used in the context of an EJB, one technique  
that might work is to declare an @Resource reference to the datasource  
at the top of that bean's class.  That will cause it to be available  
to any code executing in the scope of that ejb via that name in JNDI.

As far as accessing java:openejb, I think we need to revise our code  
here.  Without going into too many details, the java:openejb isn't  
available in all situations.  It's really only available when doing a  
"new InitialContext().lookup("java:openejb")" from outside the scope  
of an ejb or servlet (say in a test case).  From inside the scope of  
an ejb or servlet you get their private JNDI scope which doesn't  
include java:openejb (it should).  When doing a lookup via "new  
InitialContext(properties).lookup("java:openejb)" with the properties  
listing the LocalInitialContextFactory you get an ejb-only namespace  
where java:openejb isn't there (again, it should).  We need to fix up  
those namespaces.

Trying roll a 3.1 release at the moment, but this is definitely  
something we'll fix up immediately after.  And hopefully get a 3.1.1  
out very soon after 3.1.


View raw message