users@glassfish.java.net

Re: JNDI question

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Tue, 23 Oct 2007 14:00:59 -0400

ctx.lookup("java:comp/env/something") does a lookup in the private
naming context inside JavaEE environment (doesn't work outside of a
container). Entry names in java:comp/env/ and its subcontexts are
logical reference names that are mapped to the physical names in the
appsever. When you create a resource in admin console you assign it a
physical name (jndi-name).

For example, for ctx.lookup("java:comp/env/something") to work, the
server is looking for a <ejb-ref> or <resource-ref> or
<resource-env-ref> whose name is "something". You can declare and map
these references with injections or deployment descriptors.

Lookup by global names (ctx.lookup("something")) is not portable across
appservers.

-cheng