Wednesday, June 9, 2010

OSB JEJB, exposing a OSB Proxy Service Message Flow as a EJB

Manual is here
http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15866/jejb.htm#OSBDV1036

Further elaboration on this topic is available here:

http://biemond.blogspot.com/2010/06/jejb-transport-and-manipulating-java.html

If you create a Proxy Service as "Transport Typed Service", your only option is JEJB.

With Business Service you have EJB, JEJB and FLOW.

You should write the Interface:

package com.acme.jejb;

public interface EmployeeService {
    EmployeeResponse fireEmployee(Employee emp);
}


and the Employee and EmployeeResponse classes (omitted for clarity).
You package this in a Client Jar and use it in the definition of the PS. No implementation is required, since the Service will be the OSB Message Flow itself.

The nasty surprise it that you cannot test the PS from the Console, it says "the service is not testable since all its operations require Java arguments".

Yet if you go to the WebLogic Console, Deployments, you will see a new EJB module
_JEJB_ALSB_1276103248594 deployed in a EAR:

C:\ bea11\ user_projects\ domains\ osbdomain\ sbgen\ alsb_jejb_transport\ _JEJB_ALSB_1276103248594\ build\ dist\ _JEJB_ALSB_1276103248594. ear

with a Deployment Plan

C:\ bea11\ user_projects\ domains\ osbdomain\ osb\ config\ plan\ Plan-_JEJB_ALSB_1276103248594. ear. xml

and inside the EAR you have a Jar containing the Interface you specified in the service.

Inside you find also the Stateless Session Bean generated for you by OSB:



import com.bea.wli.sb.transports.jejb.gen.inb.BaseInboundEJBHelper;


import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.ejb.TransactionAttributeType;
import javax.ejb.Remote;


@Stateless(mappedName="EMPPS")
@Remote
@TransactionManagement(value=TransactionManagementType.CONTAINER)
public class CoherenceEJBProject_EMPPSBean extends BaseInboundEJBHelper implements com.acme.jejb.EmployeeService{


private final String targetNS = "http://www.openuri.org/";


@TransactionAttribute(value=TransactionAttributeType.SUPPORTS)
public com.acme.jejb.EmployeeResponse fireEmployee(
com.acme.jejb.Employee arg0 )
{
Object[] paramValues = new Object[1];
Class[] paramClasses = new Class[1];
String[] paramNames = new String[1];
// copy parameter values and classes into their arrays
paramValues[0] = arg0;
paramClasses[0] = com.acme.jejb.Employee.class;
paramNames[0] = "arg0";
// call the pipeline
try {
return (com.acme.jejb.EmployeeResponse) callPipeline("ProxyService$CoherenceEJBProject$EMPPS", "Archive$CoherenceEJBProject$employee", "fireEmployee", paramClasses,
paramValues, paramNames, true, targetNS, "com.acme.jejb.EmployeeResponse",
"Supports", true,
false);


} catch (Error e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (java.lang.reflect.InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t instanceof Error) throw ((Error) t);
if (t instanceof RuntimeException) throw ((RuntimeException) t);
// check each declared exception
// obscure checked exception thrown as wrapped - ERROR!
throw new RuntimeException("Unsupported checked exception thrown wrapped", t);
}
} // end fireEmployee method definition
} // end CoherenceEJBProject_EMPPS class definition


Incidentally, com.bea.wli.sb.transports.jejb.gen.inb.BaseInboundEJBHelper is in
C:\bea11\Oracle_OSB11\lib\transports\jejb_transport.jar


Besides, some configuration is made available in

C:\bea11\user_projects\domains\osbdomain\osb\config\core\YOUR_OSB_PROJECT

in an XML fragment which contains the configuration of the PS (nothing particularly exciting).


At this point most likely you will notice the exception:

java.lang.NoClassDefFoundError: com/bea/wli/sb/transports/jejb/gen/inb/BaseInboundEJBHelper

YET the component seems to be deployed OK.


The JNDI Tree will contain these entries:

_JEJB_ALSB_1276103248594CoherenceEJBProject_EMPPS_jarCoherenceEJBProject_EMPPSEJB_EmployeeService

and

_JEJB_ALSB_1276103248594CoherenceEJBProject_EMPPS_jarCoherenceEJBProject_EMPPSEJB_Home


weblogic.ejb.container.internal.StatelessEJBHomeImpl_1033_WLStub

and now how shall I cast the JNDI lookup and make a remote call? I don't have the Remote interfaces here...

WIP

No comments: