On Jul 7, 2008, at 12:39 PM, Petr Slechta wrote:
> 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?
Hi Petr,
No, it's not a contradiction as these are referring to names from two
different namespaces.
The java:comp/env names are part of each component's private component
environment. Each EJB
component, web application, and Application Client has its own
component environment namespace.
These names are selected by the developer and are portable. Each
refers to an environment
dependency, which is a level of indirection for resolving target
physical resources.
The global JNDI names are vendor-specific names used to identify
global resources (Remote EJBs, JMS Queues, Datasources)
across a particular product. These names are not portable, although
we are planning to remedy that in Java EE 6.
>
> 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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>