[AIX Solaris HP-UX Linux Windows][z/OS]

Using EJB bindings in SCA applications in a cluster environment (deprecated)

Use this task to learn how to use Enterprise JavaBeans (EJB) bindings that are deployed in Service Component Architecture (SCA) applications in a cluster environment.

Service side

When an SCA service is exposed with a binding.ejb element, the service is exposed through an enterprise bean. During deployment, the SCA runtime generates a session bean for the service that is exposed through EJB binding. The caller of the composite service can invoke this service by accessing the generated EJB.
If the service is exposed through an EJB 2 bean, the EJB is bound at:
ejb/sca/ejbbinding/component_name/service_name
For example:
ejb/sca/ejbbinding/CompanyComponent/Company
If the service is exposed through an EJB 3.x bean, the EJB is bound at:
ejb/sca/ejbbinding/component_name/service_name#fullyQualifiedServiceInterfaceNameRemote
For example:
ejb/sca/ejbbinding/CompanyComponent/Company#com.app.jobbank.CompanyRemote

The generated EJB for the composite service will be under profile_root/installedApps/cell_name/composite_name.ear/.

Callers need to include client required classes (such as remote or home) of this generated bean in their classpath (or bundle the classes in their JAR file).

Lookup and invoke of this generated service EJB from a clustered environment is the same as lookup and invoke of any EJB in a product clustered setup. Refer to the Naming considerations in clustered and cross-server environments in the EJB 3.x application bindings overview topic.

Reference side

When used on the reference side, the binding.ejb element should specify a URI attribute with values that match the value that is typically used when an EJB client calls the initialContext.lookup() method. The general convention is:
"corbaname:iiop:host:port/NameServiceServerRoot#JNDI_name"
where JNDI_name is the JNDI name of the target EJB.

For example:

uri="corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/session/PriceQuoteSessionFacadeBean" 

JNDI name syntax differs if the target EJB is an EJB 2 or EJB 3.x bean.

When the referred EJB service is in a different cell, the URI might resemble one of the following:

uri="corbaname:iiop:localhost:2809/NameServiceServerRoot#cell/clusters/cluster1/ejb/session/PriceQuoteSessionFacadeBean"
or
uri="corbaname::/NameServiceServerRoot#cell/clusters/cluster1/ejb/session/PriceQuoteSessionFacadeBean"
or
uri="cell/clusters/cluster1/ejb/session/PriceQuoteSessionFacadeBean"
if the target EJB is on the same machine but on different cluster.

In advanced scenarios on multiple-server environments, a simpler and more portable way to access the target EJB application from an SCA composite is to set up a namespace binding and use the namespace binding name in the URI attribute of the binding.ejb along with cell/persistent/. For example:

uri="cell/persistent/PriceQuote"

where PriceQuote is the name field in the namespace.

The namespace binding can be of type EJB or CORBA based on the advanced scenario.

If the target EJB application which the composite is trying to access is on same cell, but on a different server, node or cluster, configure an EJB namespace binding. You can do this from the administrative console:

  1. Click Environment > Naming > Name space bindings.
  2. Select the cell scope.
  3. Click New.
  4. On the Specify binding type page, select the EJB binding type.
  5. On the Specify basic properties page, specify the binding identifier, name in namespace, enterprise bean location such as server cluster or single server (with node), and JNDI name as needed. Use the Name in name space field to construct the URI as cell/persistent/name_in_namespace.
If the composite is running on a Version 7.0 cell and the target EJB application is running on a Version 6.1 product, configure a CORBA namespace binding with the correct Corbaname URL of the target EJB. Example Corbaname URL syntax is:
"corbaname:iiop:host:port/NameServiceServerRoot#jndi_name"

After you configure the namespace binding, use the Name in name space field to construct the URI; for example, uri="cell/persistent/PriceQuote" where PriceQuote is the value in the Name in name space field of the binding.

An advantage of using a namespace binding is, even when the target EJB changes, the composite definition does not need to change. Only the namespace binding needs to change accordingly.

SCA EJB reference binding URI patterns

Use an EJB reference binding URI pattern that is appropriate for the user setup and configuration:
  • If an EJB reference binding accesses a stateless session bean on the same server, the EJB reference binding URI can be a Java™ Naming and Directory Interface (JNDI) name of the stateless session bean. For example:
    uri="ejb/com/app/resumebank/ResumeBankHome"
  • If the EJB reference binding references another SCA service with the EJB binding on the same server, then the EJB reference binding URI can be either of the following:
    • The JNDI name of the stateless session bean. For example,
      uri="ejb/com/app/resumebank/ResumeBankHome"
    • A binding that uses the SCA reference target mechanism instead of the binding URI:
      <reference name="service1" target=”component_name/service_name”>
      .... 
      <binding.ejb/>
      </reference>
  • If the EJB reference binding is accessing a stateless session bean that is deployed in the same cell, the EJB reference binding URI can be based on the cluster/node/server setup. See the following examples:
    • Accessing a stateless session bean deployed in the same cell and on cluster2
      uri="cell/clusters/cluster2/ejb/com/app/resumebank/ResumeBankHome"
    • Accessing a stateless session bean deployed in the same cell but on a different node.
      uri="cell/nodes/node_name/servers/server_name/ejb/com/app/resumebank/ResumeBankHome"
  • If an EJB reference binding accesses a stateless session bean on a cell other than the current cell or on a mixed cell, then you can configure a reference binding URI in either of the following ways:
    • Create a namespace binding of either a Corba or EJB type using the administrative console. After configuring the namespace binding, use the Name in name space value to construct the URI as:
      uri="cell/persistent/name_in_namespace_binding"
      For example, if neworder is the name in the namespace binding, then the URI is uri="cell/persistent/neworder".
    • Use corbaname for the EJB reference binding URI. For example:
      corbaname:iiop:<hostName><port>/NameServiceServerRoot#jndi_name 
      where hostName and port are the respective host and port, and where the target stateless session bean is running. jndi_name is the JNDI name of the EJB which differs between EJB2 and EJB3.