Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring an Environment Reference to a Remote EJB: Clustered or Combined Web Tier and EJB Tier

In a clustered OC4J architecture or a single-instance OC4J architecture with both Web tier and EJB tier on the same OC4J instance, you can define an EJB reference to the remote interface of a target enterprise bean using one of the following approaches (in increasing order of assembly and deployment flexibility):

Note:

In EJB 3.0, an environment reference to a target enterprise bean is not needed. You can access a target enterprise bean directly using resource injection (see "Accessing an EJB 3.0 Enterprise Bean").

For an unclustered architecture, in which the Web tier and EJB tier are deployed to separate OC4J instances on different hosts, see "Configuring an Environment Reference to a Remote EJB: Unclustered Separate Web Tier and EJB Tier".

For information on looking up a target enterprise bean, see "Accessing an Enterprise Bean From a Client".

Configuring ejb-ref in the Client: No Indirection

Choose this option if the bean interfaces are unique (for example, only one session bean uses the interface Cart.class), or you do not want to use indirection that offers some assembly and deployment flexibility:

  1. Define an <ejb-ref> element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-1 shows:

    • <ejb-ref-name>: the actual name of the target enterprise bean.

    • <ejb-ref-type>: the type of the target enterprise bean, one of Session or Entity.

    • <home>: the package and class name of the target enterprise bean's remote home interface.

    • <remote>: package and class name of the target enterprise bean's remote component interface.

    Example 19-1 Configuring ejb-ref-name

    <ejb-ref>
     <ejb-ref-name>myBeans/BeanA</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>myBeans.BeanAHome</home>
     <remote>myBeans.BeanA</remote>
    </ejb-ref>
    

Configuring ejb-ref in the Client: Using ejb-link to Resolve Indirection

Choose this option if the bean interfaces are not unique or, if you want to use indirection that offers some assembly and deployment flexibility:

  1. Define an <ejb-ref> element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-2 shows:

    • <ejb-ref-name>: the logical name of the target enterprise bean.

    • <ejb-ref-type>: the type of the target enterprise bean, one of Session or Entity.

    • <home>: the package and class name of the target enterprise bean's remote home interface.

    • <remote>: package and class name of the target enterprise bean's remote component interface.

    • <ejb-link>: the actual name of the target bean.

    Example 19-2 Configuring ejb-ref-name with a Logical Name Resolved by ejb-link

    <ejb-ref>
     <ejb-ref-name>ejb/nextVal</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>myBeans.BeanAHome</home>
     <remote>myBeans.BeanA</remote>
     <ejb-link>myBeans/BeanA</ejb-link>
    </ejb-ref>
    

Configuring ejb-ref in the Client: Using orion-ejb-jar.xml ejb-ref-mapping to Resolve Indirection

Choose this option, if the following is true:

  • The bean interfaces are not unique.

  • You want to use indirection that offers the most assembly and deployment flexibility.

  1. Define an <ejb-ref> element in the appropriate client deployment descriptor (see "Where do you Configure an EJB Environment Reference?") and configure the following subelements, as Example 19-3 shows:

    • <ejb-ref-name>: the logical name of the target enterprise bean.

    • <ejb-ref-type>: the type of the target enterprise bean, one of Session or Entity.

    • <home>: the package and class name of the target enterprise bean's remote home interface.

    • <remote>: package and class name of the target enterprise bean's remote component interface.

    Example 19-3 Configuring ejb-ref-name With a Logical Name Resolved by ejb-ref-mapping

    <ejb-ref>
     <ejb-ref-name>ejb/nextVal</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>myBeans.BeanAHome</home>
     <remote>myBeans.BeanA</remote>
    </ejb-ref>
    
  2. Within the orion-ejb-jar.xml deployment descriptor, define an <ejb-ref-mapping> element that maps the logical name to the actual name of the target bean, as Example 19-4 shows.

    Example 19-4 Mapping Logical Name to Actual Name With ejb-ref-mapping

    <ejb-ref-mapping name="ejb/nextVal" location="myBeans/BeanA"/>
    

    As Figure 19-1 shows, in the <ejb-ref-mapping> element, configure the name attribute to match the <ejb-ref-name> and configure the location attribute with the actual name of the target bean. In Example 19-4, the logical name ejb/nextVal is mapped to the actual name of the target bean myBeans/BeanA.

    Figure 19-1 Associating ejb-ref-name and ejb-ref-mapping

    Description of Figure 19-1 follows
    Description of "Figure 19-1 Associating ejb-ref-name and ejb-ref-mapping"

    OC4J maps the logical name to the actual JNDI name on the client side. The server side receives the JNDI name and resolves it within its JNDI tree.