DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
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:
<session>
<ejb-name>SampleBean</ejb-name>
<business-remote>com.ibm.wasce.samples.SampleBeanRemote</business-remote>
<business-local>com.ibm.wasce.samples.SampleBeanLocal</business-local>
<ejb-class>com.ibm.wasce.samples.SampleBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
and in its openejb-jar.xml:
<dep:moduleId>
<dep:groupId>com.ibm.wasce.samples</dep:groupId>
<dep:artifactId>SampleEJB</dep:artifactId>
<dep:version>2.1.1.1</dep:version>
<dep:type>jar</dep:type>
</dep:moduleId>
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.
<dep:dependency>
<dep:groupId>com.ibm.wasce.samples</dep:groupId>
<dep:artifactId>SampleEJB</dep:artifactId>
<dep:version>2.1.1.1</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
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.
<nam:ejb-ref>
<nam:ref-name>ejb/SessionBean</nam:ref-name>
<nam:ref-link>SampleBean</nam:ref-link>
</nam:ejb-ref>
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:
<ejb-ref>
<ejb-ref-name>ejb/SessionBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>com.ibm.wasce.samples.SampleBeanRemote</remote>
</ejb-ref>
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.
<nam:ejb-local-ref>
<nam:ref-name>ejb/SessionBean</nam:ref-name>
<nam:ejb-link>SampleBean</nam:ejb-link>
</nam:ejb-local-ref>
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:
<ejb-local-ref>
<ejb-ref-name>ejb/SessionBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.ibm.wasce.samples.SampleBeanLocal</local>
</ejb-local-ref>
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.