tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: simple binding to global jndi
Date Sat, 02 Jul 2011 06:07:06 GMT

On Jul 1, 2011, at 10:57 AM, David Latil wrote:

> This seems like such an easy question, but I haven't been able to do it yet.
> I have ejb application I am testing using embedded openejb.  One of my ejb's has this
in its ejb-jar.xml
> <resource-env-ref>
>                <resource-env-ref-name>configURL</resource-env-ref-name>
>                <resource-env-ref-type></resource-env-ref-type>
>            </resource-env-ref>
> I need to bind a URL into the global JNDI namespace.  I can do it when I am testing the
ejb itself using the, but when I am pulling in the ear as a .jar
file into my integration tests, I can't seem to get the env-properties to work.  So I figured
I would just inject directly into the InitialContext using .bind, but that didn't work because
I believe the injection had already taken place and it couldn't find the global jndi entry.
> How do you bind objects  (other than EJB's, Resources) to global JNDI so that they can
be picked up later for injection.  This seems simple, I must be missing something.  Everything
I try keeps giving me "warning Injection data not found in JNDI context: ...."

Tricky thing is that Java EE 5 / EJB 3.0 doesn't have the concept of global JNDI.  Each individual
EJB is required to get it's very own private JNDI java:comp/env namespace and only it is allowed
to see it or have names added to it via the deployment descriptor.  So no sharing at all is
possible.  In OpenEJB 3.x we do have the concept of a non-standard OpenEJB-specific global
JNDI, but it is limited to looking up EJBs.

The reason the file appears global is because we basically read that
file in and create an <env-entry> for each EJB in the app.  So it ends up feeling fairly
global, but the truth is that it is that each EJB has it's own copy of that entry.  Clients
that are not EJBs themselves, only get to see the "EJB only" global JNDI and have no ability
to peek into the private JNDI namespace of any particular EJB.

That said, Java EE 6 does have an official and standard concept of Global JNDI (finally!)
and OpenEJB 4.0.0-SNAPSHOT (trunk code nearing beta) does support this.  There are actually
a few new JNDI namespaces and each has a different sharing scope.  They are:

 - java:global/
 - java:app/
 - java:module/
 - java:comp/env (the existing namespace)

Probably not exactly the response you were hoping for, but I hope good news all the same :)


View raw message