When I tried to call BPEL process from JAVA following the steps given in BPEL developer guide, I got error:
java.lang.Exception: Failed to create "ejb/collaxa/system/DeliveryBean" bean. exception reported is: "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
Then I added code to set initial context and it worked.
I hope following example will be helpful to you.
import com.oracle.bpel.client.Locator;
import com.oracle.bpel.client.dispatch.IDeliveryService;
import com.oracle.bpel.client.NormalizedMessage;
import java.util.Hashtable;
import java.util.Map;
import javax.naming.Context;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class BpelClient {
public BpelClient() {
}
public static void main(String[] args) {
try {
// Set Initial context
Hashtable jndi = new Hashtable();
jndi.put(Context.PROVIDER_URL, "ormi://localhost:12401/orabpel");
jndi.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
jndi.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
jndi.put(Context.SECURITY_CREDENTIALS, "welcome1");
jndi.put("dedicated.connection", "true");
//Instantiate locator
Locator locator = new Locator("default", "bpel", jndi);
IDeliveryService deliveryService = (IDeliveryService)locator.lookupService(IDeliveryService.SERVICE_NAME );
//Prepare input message
String xml = "
NormalizedMessage nm = new NormalizedMessage( );
nm.addPart("payload", xml );
// Call CreditRatingService BPEL process
NormalizedMessage res =
deliveryService.request("CreditRatingService", "process", nm);
System.out.println( "BPELProcess CreditRatingService executed!" );
// Print output
Map payload = res.getPayload();
Element part = (Element)payload.get("payload");
Node outputElement = part.getFirstChild();
System.out.println("Rating: " + outputElement.getNodeValue());
} catch (Exception ex) {
ex.printStackTrace();
} finally {
}
}
}
Subscribe to:
Posts (Atom)