Configuring EJB bindings in SCA applications

Use this task to learn how to use Enterprise JavaBeans™ (EJB) bindings in SCA applications.

Support is provided for EJB bindings in 2.x and 3.0-style beans, for service, reference, and reference target.

The EJB bindings do not support interface.wsdl files.

The following is an example of an composite definition that has a service exposed over an EJB 3.0 binding:
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://neworder/sca/jdbc" 
name="NewOrderComposite">

<component name="NewOrderEJB3ServiceComponent">
<implementation.java class="neworder.sca.jdbc.NewOrderServiceImpl" requires="managedTransaction.local"/>
<service name="NewOrderService" requires="suspendsTransaction">
<interface.java interface="neworder.sca.jdbc.NewOrderService"/>
<binding.ejb ejb-version="EJB3"/>
</service>
</component>
</composite>
A client that wants to invoke the resultant enterprise bean would treat it like any other enterprise bean and not like a regular SCA service. CompositeContext.getService is not supported for a non-SCA binding, therefore, a getService() on the CompositeContext would not work here. The following is the client code for the above example:
InitialContext ctxt = new InitialContext();  Object remoteObj = ctxt.lookup("ejb/sca/ejbbinding/NewOrderEJB3ServiceComponent/NewOrderService#neworder.sca.jdbc.NewOrderServiceRemote");  NewOrderServiceRemote newOrderRemote = (NewOrderServiceRemote) PortableRemoteObject.narrow(remoteObj, NewOrderServiceRemote.class); 
The following is an example of an composite definition that contains references to both EJB 2.x and EJB 3.0 bindings:
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://erww.workload" name="ConvertComposite">

<component name="ConvertInputOutputServiceComponent">
<implementation.java class="convert.inputoutput.sca.ConvertInputOutputServiceImpl"

<reference name="priceQuoteSessionReference">
<interface.java interface="priceQuoteSession.PriceQuoteSession"/>
<binding.ejb uri="corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/session/PriceQuoteSessionFacadeBean"/>
</reference>
</component>
</composite>

Different binding.ejb attributes can be used for service side EJB bindings or reference side EJB bindings. The following information explains how the default value is calculated for each side:

Service side

The service side EJB binding applies only to Java™ archive (JAR)-packaged SCA applications. When an SCA service is exposed through an EJB service binding, the service is exposed through an enterprise bean. During deployment, the SCA runtime generates a session bean for the service exposed through the EJB binding. The caller of the composite service can invoke this service by accessing the generated enterprise bean as if they are invoking any enterprise bean.

The generated enterprise bean for the composite service is in the directory, WAS_HOME\AppServer\profiles\PROFILE_NAME\installedApps\CELL_NAME\COMPOSITE_NAME.ear\. Callers need to include the client required classes, such as remote or home, of the generated bean in the classpath or bundle the classes in the JAR file.

Reference side

The reference side EJB binding applies to both JAR-packaged applications and Web archive (WAR)-packaged applications, if not otherwise stated.
Attention: A lookup issue for EJB 3.0 reference bindings might occur when the URI follows the corbaname:iiop:host:port/NameServiceServerRoot##<ejb3_binding_longform> pattern This problem exists only for EJB 3.0 reference bindings. When the EJB 3.0 reference binding URI follows the corbaname:iiop:host:port/NameServiceServerRoot##<ejb3_binding_longform> pattern, where ejb_binding_longform is ejb/<component-id#<package.qualified.interface>, and if more than one enterprise bean that is implementing the same interface is deployed on that server, lookup may not be directed to the correct EJB with corresponding component ID.
An example of a URI where this problem can occur is as follows:
uri="corbaname:iiop:host:port/NameServiceServerRoot#ejb/EJB3CounterSample/EJB3Beans.jar/StatelessCounterBean#com.ibm.websphere.ejb3sample.counter.RemoteCounter
There are two enterprise beans implementing the com.ibm.websphere.ejb3sample.counter.RemoteCounter interface. To avoid this issue: To resolve this problem, follow these guidelines:

Different patterns of the SCA EJB reference binding URI are based on the user setup and configurations. If the SCA EJB reference binding is accessing a stateless session bean on the same server, the EJB reference binding URI can be designated as the JNDI name, uri="ejb/com/app/resumebank/ResumeBankHome". If the SCA EJB reference binding is referencing another SCA service with an EJB binding in the same server, the URI can be designated as the JNDI name, uri="ejb/com/app/resumebank/ResumeBankHome" or you can use the <reference target=<componentName/serviceName> instead of the URI.

If the EJB reference binding is accessing a stateless session bean that is deployed in the same cell, the URI can be based on cluster/node/server setup, for example:
uri="cell/clusters/cluster2/ejb/com/app/resumebank/ResumeBankHome" 
uri="cell/nodes/<node_name>/servers/<server_name>/ejb/com/app/resumebank/ResumeBankHome"
If the EJB reference binding is accessing a stateless session bean on a different cell (cross cell) or a mixed cell, you need to create a namespace binding, either an enterprise bean or Corba type, in the WebSphere® Application Server administrative console and use the name in namespace binding in EJB reference binding URI such as, uri="cell/persistent/<name_in_namespace_binding>". For example, uri="cell/persistent/neworder" where neworder is name in the namespace binding.

SCA EJB Session Bean Binding

Table 1. Unsupported sections of the SCA EJB Session Bean Binding specification. This table lists specification sections that the feature pack does not support.
Section Not supported in Feature Pack for SCA v1.0
2.1 Session Bean Binding Schema /binding.ejb/@session-type
  • Since Feature Pack for SCA does not support conversations, although session-type is set to "stateful", the service still behaves as stateless.
/binding.ejb/@uri
  • Line 91: Feature Pack for SCA only supports the following formats:
    • For EJB2
      corbaname:iiop:<hostName>:<port>/NameServiceServerRoot#ejb/sca/ejbbinding
      /<componentName>/<serviceName> 
    • For EJB3
      corbaname:iiop:<hostName>:<port>/NameServiceServerRoot#ejb/sca/ejbbinding/<componentName>
      /<serviceName>#<serviceInterfaceName>Remote or corbaname:iiop:<hostName>:<port>
      /NameServiceServerRoot#<serviceInterfaceName>Remote
  • Line 97: corbaname:rir:#ejb/MyHome
2.3.1 Conversational Nature of Stateful Session Beans Lines 197-229



Concept topic    

Terms of Use | Feedback

Last updated: Oct 22, 2010 3:02:28 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v700osgijpa&product=was-nd-mp&topic=tsca_ejb_binding
File name: tsca_ejb_binding.html