HomeDocumentation > Creating deployment plans > Creating deployment plans for applications > Naming (JNDI) > EJB naming

The naming space xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.2" defines following tags used to reference EJB resources in a deployment plan.

Reference Type

Tags

Usage

EJB reference

<nam:ejb-ref/>

Reference EJB remote interface

EJB reference

<nam:ejb-loc-ref/>

Reference EJB local interface

EJB reference

For example, a EJB session bean is defined in its ejb-jar.xml:

and in its openejb-jar.xml:

To reference this session bean in a Java EE application, you first have to define the dependency on this bean and then use the <ejb-ref> or <ejb-local-ref> element to map a reference to the EJB's home interface.

EJB remote reference

You can use the <ejb-ref> element in your deployment plan to map a reference to an EJB's remote home interface.

The <ref-name> element is the name of the remote home interface used in your module. The JNDI name used for this example will be java:/comp/env/ejb/SessionBean and it should map to the ejb-ref-name provided in the Java EE deployment descriptor:

Now you can reference the EJB in the application by the JNDI name java:comp/env/ejb/SessionBean.

EJB local reference

You can use the <ejb-local-ref> element in your deployment plan to map a reference to an EJB's local home interface.

The <ref-name> element is the name of the local home interface used in your module. The JNDI name used for this example will be java:/comp/env/ejb/SessionBean and it should map to the ejb-ref-name provided in the Java EE deployment descriptor:

Now you can reference the EJB in the application by the JNDI name java:comp/env/ejb/SessionBean.

Global JNDI reference for EJB objects

Session beans and entity beans will be bound automatically into a global JNDI context. An EJB's JNDI name is in the following format:

{deploymentId}{interfaceType.annotationName}

You can customize the global JNDI name. See OpenEJB JNDI names for more details about JNDI name formatting.