Show TOC Start of Content Area

Procedure documentation Declaring EJB References  Locate the document in its SAP Library structure

Use

If your bean accesses (looks up) other enterprise beans, you have to declare an EJB reference for each bean that is referenced. If your bean will access the referenced bean locally, you have to declare a local EJB reference (by using the <ejb-local-ref> element). If your bean will access the referenced bean remotely, you have to declare a remote EJB reference (by using the <ejb-ref> element).

Procedure

...

       1.      Open the ejb-jar.xml

       2.      From the right-hand pane, choose the Enterprise Beans tab

       3.      Open the corresponding tree structure according to the type of your enterprise bean (session, entity, or message-driven)

       4.      From your bean tree sub-structure, select ejb-ref (if you want to declare references to home interfaces) or ejb-local-ref (if you want to declare references to local home interfaces)

       5.      Choose add.

A dialog box appears.

       6.      Choose the enterprise beans, to which you want to declare EJB references.

The selected enterprise beans appear as sub-nodes under the ejb-ref or the ejb-local-ref node correspondingly. The required fields are automatically completed. You can modify the EJB Reference Name and specify a description for the EJB reference.

       7.      Optionally, you can specify the EJB Link. The value of this field must be:

¡        If the referenced bean will be deployed as part of the same JAR as the referencing bean – the ejb-name of the referenced bean.

¡        If the referenced bean will be deployed as part of another JAR but within the same J2EE application unit – <the path to the referenced bean’s JAR file>#<the ejb-name of the referenced bean>

¡        If the referenced bean will be deployed in another J2EE application, leave this field empty.

 

Note

To remove an EJB reference, select it and choose Remove.

If the information in the <ejb-ref> or <ejb-local-ref> element is not sufficient to identify the referenced bean (for example, more than one bean with the same interfaces is deployed on the J2EE Engine), you also have to define the referenced bean that will be accessed by your enterprise bean. Therefore, you have to specify the JNDI name of the referenced enterprise bean (that is, the name under which the referenced bean is registered in the JNDI namespace) in the ejb-j2ee-engine.xml. In such cases proceed as follows:

       8.      Open the ejb-j2ee-engine.xml.

       9.      From the right-hand pane, choose the Enterprise Beans tab.

   10.      Open the corresponding tree structure according to the type of your enterprise bean (session, entity, or message-driven).

   11.      From your bean tree sub-structure, select ejb-ref or ejb-local-ref accordingly.

   12.      Choose Add.

A dialog box, which contains the corresponding EJB references declared in ejb-jar.xml, appears.

   13.      Choose the EJB reference and select OK.

The EJB reference appears in the enterprise bean tree structure.

   14.      In the right-hand pane, specify the JNDI name of the referenced bean:

                            a.      By default, this value is <application provider>/<application name>/<EJB name>, where:

§         <application provider> is the name of the application provider as specified in the <provider-name> element of the referenced bean’s application-j2ee-engine.xml,

§         <application name> is the name of the application as specified in the <display-name> element of the referenced bean’s application.xml,

§         <EJB name> is the name of the referenced bean as specified in the <ejb-name> element of the referenced bean’s ejb-jar.xml.

                            b.      If you have already specified a custom JNDI name for the referenced bean in its ejb-j2ee-engine.xmldescriptor (which is not recommended), the value of this field must be the same.

Result

When you look up the referenced enterprise bean, use the name that you have specified in the EJB Reference Name field in step 6 above. This name is stored in the <ejb-ref-name> tag of the corresponding EJB reference in the ejb-jar.xmldeployment descriptor of the referencing enterprise bean.

If you look up enterprise beans from another J2EE application, in the application-j2ee-engine.xml of your EJB application you have to declare a reference to the referenced beans’ application. For more information, see Editing Application References.

 

 

End of Content Area