Binding EJBs in JNDI
This page outlines how the JNDI binding of EJBs works. It shows how to configure an EJBs to be bound into JNDI at certain locations and how the EJB is bound when there is no location specified.
By default beans have a base JNDI name in the form "[<app-name>/]<bean-name>" regardless which interfaces are defined on the bean. Depending on whether an EJB3 deployment is packaged within an EAR the JNDI name will be prepended by the short name of the EAR. So for foo.ear/bar.jar/MyBean it will become "foo/MyBean". Depending on which views the EJB 3 bean exposes the final JNDI name becomes:
- "[<app-name>/]<bean-name>/home" for EJB 2.1 home view;
- "[<app-name>/]<bean-name>/localHome" for EJB 2.1 local home view
- "[<app-name>/]<bean-name>/remote" for an EJB 3 business remote view implementing all business remote interfaces (1)
- "[<app-name>/]<bean-name>/local" for an EJB 3 business local view implementing all business local interfaces (1)
For each interface there is also a separate binding to allow getInvokedBusinessInterface to function:
The final JNDI name can be overriden with the use of @RemoteHomeBinding, @LocalHomeBinding, @LocalBinding, @RemoteBinding or the equivalents from jboss.xml (home-jndi-name, local-home-jndi-name, local-jndi-name or jndi-name).
Note that currently jndi-name and mapped-name are interpreted equally.
It is possible to specify the same JNDI name for both remote home and remote business proxy (or the local equivalents). In that case a single proxy will be bound on that JNDI name implementing the remote home interface and all the remote business interfaces (1).
- CAVEAT: In case of conflicting method signatures a call to that proxy might throw an UndeclaredThrowableException or behave differently than expected. The only solution is doing a finer grained lookup. (EJBTHREE-786 and EJBTHREE-1222)
For backwards compatibility: http://www.jboss.org/jbossejb3/docs/tutorial/jndibinding/jndi.html