Saturday, March 22, 2008

Tips on the Oracle BPEL Java API - Part 1 - Using the Server class to get a list of domains

In this post I'll describe some of the common things that need to be done to call the Oracle BPEL PM API from Java, and I'll show you how to put that to use to get a list of the current BPEL domains defined on you server. We'll be using the Server class, which is in the com.oracle.bpel.client package, and is useful for manipulating BPEL at the server level.

First, for this example, you'll need to import several BPEL API classes:

import com.oracle.bpel.client.BPELDomainStatus;
import com.oracle.bpel.client.Server;
import com.oracle.bpel.client.auth.ServerAuth;
import com.oracle.bpel.client.auth.ServerAuthFactory;

The next task is to configure a java.util.Properties object with the connection information for your BPEL server, as well as a String object containing the security credentials (password):

Properties props = new java.util.Properties();
props.put("orabpel.platform", "ias_10g" );
props.put("java.naming.factory.initial",
"com.evermind.server.rmi.RMIInitialContextFactory" );
props.put("java.naming.provider.url",
"opmn:ormi://bpelserver:6003:home/orabpel" );
props.put("java.naming.security.principal", "oc4jadmin" );
props.put("java.naming.security.credentials", "password123" );

String securityCredentials = "password123";

We are now ready to get a ServerAuth object from the ServerAuthFactory:

ServerAuth auth = ServerAuthFactory.authenticate(securityCredentials, null, props);


Next, we get an actual client connection to the server by creating a Server object and passing the constructor our ServerAuth object:


Server srv = new Server(auth);

Finally, we can get the list of domain status information by calling the getAllDomainStatus() method of the server:

BPELDomainStatus domainList[] = srv.getAllDomainStatus();

Now that you have the status information you can do any number of things, in our example we can print out the domain ID of each domain on the server with this code:

for (int i=0; i<domainList.length; i++ ) {
System.out.println( "Domain ID="+domainList[i].getDomainId() );
}

2 comments:

Unknown said...

Hi Charles,
I tried your code, I got an java.lang.Exception: Failed to create "ejb/collaxa/system/ServerBean" 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

Is there a resource that I need to add?

I am running the program in JDeveloper. My environment is :
BPEL Designer 10.1.3.3.0 (Build 070615.0525)
Java(TM) Platform 1.5.0_06
Oracle IDE 10.1.3.41.57

Charles Piazza said...

This exception is usually thrown when the connection string information supplied is not correct. Most likely this is a problem with the RMI port -- which for me was 6003, but may be different depending on your installation.