ejb@glassfish.java.net

Default JNDI names for EJBs

From: Petr Slechta <Petr.Slechta_at_Sun.COM>
Date: Mon, 07 Jul 2008 18:39:30 +0200

Hi all,

I read several blogs and everybody says that default names for EJBs are
not part of the specification. So every server may use its own naming
convention.

However, if I look into ejb-3_0-fr-spec-ejbcore.pdf, there is the
following paragraph:

>>>
16.2.2 Annotations for Environment Entries

...

A field of the bean class may be the target of injection. The field must
not be final. By default, the name of the field is combined with the
name of the class in which the annotation is used and is used directly
as the name in the bean’s naming context. For example, a field named
myDatabase in the class MySessionBean in the package com.acme.example
would correspond to the JNDI name
java:comp/env/com.acme.example.MySessionBean/myDatabase. The annotation
also allows the JNDI name to be specified explicitly.
<<<

When I read your page
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#SessionBeanGlobalJNDINameAssignment
, section "If no global JNDI name has been specified, a default global
JNDI name will be generated according to the following table", there is
a table with the following two raws:

>>>
Bean has 2.x Home/Remote interfaces / Total # of 3.0 Remote Business
interfaces / default JNDI name / example
...
Yes / 0 / fully-qualified name of Home interface / com.acme.FooHome
No / 1 / fully-qualified name Remote Business interface /
com.acme.FooBusiness
...
<<<

Is not this contradiction with the specification?
Why Glassfish uses JNDI name "com.acme.FooHome" instead of
"java:comp/env/com.acme.FooHome"?
Some other servers follow this rule... And specification is full of such
examples...

Please help me to understand this issue.

How can IDE (NetBeans) generate code to access an EJB if the code
depends on the used server?
(Now it generates JNDI name which starts with "java:comp/env/" which
seems to be the most common use case... Should not Glassfish also follow
this form of JNDI names?)

Thank you in advance for clarification!

Petr Slechta