Follow Us on Twitter

Using A Java Action Fault Policy In SOA Suite 11g

by Cyril Hak on November 12, 2009 · 9 comments

In this previous post about Error handling in SOA Suite 11G, I explained how you can create your own fault handling policy for your BPEL process.

This post describes how to call a Java action for error handling.

First we are going to create a new project in JDeveloper witch contains the Java class that will be called when an error occurs.

Add the following libraries to your project: SOA Runtime and BPEL Runtime.

Create a new Java class and let it implement the following interface: oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass.

The IFaultRecoveryJavaClass interface defines two operations: handleRetrySuccess and handleFault.

The handleRetrySuccess method is invoked upon a successful retry attempt and the handleFault method is invoked to execute a policy of type javaAction.

public interface IFaultRecoveryJavaClass {
    void handleRetrySuccess(IFaultRecoveryContext iFaultRecoveryContext) { }
    java.lang.String handleFault(IFaultRecoveryContext iFaultRecoveryContext) { }

The IFaultRecoveryContext contains methods for retrieving specified details about the error, the instance and properties you can define in the <Properties> section of the fault-policies.xml file (explained later).

Here follows a Java class example.

package nl.whitehorses.soa.demo;

import java.util.ArrayList;
import java.util.Map;

import oracle.integration.platform.faultpolicy.IFaultRecoveryContext;
import oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass;

public class FaultHandler implements IFaultRecoveryJavaClass {

    public void handleRetrySuccess(IFaultRecoveryContext iFaultRecoveryContext) {
        System.out.println("This is for retry success");

    public String handleFault(IFaultRecoveryContext iFaultRecoveryContext) {
        //print all fault details
        System.out.println("Fault policy id: " + iFaultRecoveryContext.getPolicyId());
        System.out.println("Fault type: " + iFaultRecoveryContext.getType());
        System.out.println("Partnerlink: " + iFaultRecoveryContext.getReferenceName());
        System.out.println("Port type: " + iFaultRecoveryContext.getPortType());
        System.out.println("Properties found in propertySet:");
        //print all properties defined in the fault-policy file
        Map props = iFaultRecoveryContext.getProperties();
        for (Map.Entry entry : props.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue().get(0));
        return "OK";

The Java file must be deployed as a jar file in the lib folder of the SOA-suite domain ($ORACLE_MIDDLEWARE_HOME/user_projects/domains/soa_domain/lib).

Next we have to create a BPEL process with a fault-bindings and fault-properties file, see this post.

In the fault-policies.xml file we must declare an Action of type javaAction. In the properties section we can add some properties we can use in our Java code (in this example I created a property called myProperty with the value My Porperty value).

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns=""
  <faultPolicy version="2.1.3" id="ConnectionFaults">
      <faultName xmlns:bpelx=""
          <action ref="java-fault-handler"/>
      <Action id="java-fault-handler">
        <javaAction className="nl.whitehorses.soa.demo.FaultHandler"
          <returnValue value="OK" ref="ora-human-intervention"/>
      <propertySet name="properties">
        <property name="myProperty">My Property value</property>

The next figure shows a part the output from the Managed server when the Java class is invoked.


Using A Java Action Fault Policy In SOA Suite 11g, 5.0 out of 5 based on 2 ratings
VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)

{ 9 comments… read them below or add one }

Andy November 25, 2009 at 2:04 am

I have a Java program that uses the class BPELFaultRecoveryContext below

import com.collaxa.cube.engine.fp.BPELFaultRecoveryContext;

which resides in the orabpel.jar file. I jar up the java program and put it in the $ORACLE_MIDDLEWARE_HOME/user_projects/domains/soa_domain/lib folder on the SOA server. When I run the bpel process, it will call this java class and now, when the java class runs, it said that it can’t find this class BPELFaultRecoveryContext. I searched the server and the orabpel.jar file is there. It’s in another directory though.

The intereresting thing is in this java program, it uses the below classes and they are in the fabric-runtime.jar file. I do not include the fabric-runtime.jar file in the jar file with the java class but the java program is able to locate these 2 classes but not the one above.

import oracle.integration.platform.faultpolicy.IFaultRecoveryContext;
import oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass;

Do I need to include the orabpel.jar file in the jar file with the java class? Do you have any ideas? Thanks


Sai June 3, 2010 at 5:50 pm

Were you able to get this to work?



RaviSekhar December 17, 2009 at 1:00 am


We have java action created for Mediator, but the problem we are seeing is how do we get the composite instanceID from that.



Veeru August 20, 2010 at 12:16 pm

To get composite InstanceID, you have the API IFaultRecoveryContext.getInstanceId()


rob September 13, 2010 at 8:02 pm

“The Java file must be deployed as a jar file in the lib folder of the SOA-suite domain ($ORACLE_MIDDLEWARE_HOME/user_projects/domains/soa_domain/lib).”

How do I do this in jDeveloper? Or, do I need to javac the file to a jar from the cmd line?


rob September 13, 2010 at 8:49 pm

Also, what log should this be showing up in?


Puneet January 21, 2011 at 7:03 pm


Nice article.
But is there a way to send the reply back to the caller of Bpel/mediator from the java handler ?

I can set up the Bpel variables using BPELFaultRecoveryContextImpl.setvariabledata.
But i am not able to find a way to send the reply back to Caller.

Any help/suggestion in this regard is highly appreciated.

Thanks !!


Vivek May 19, 2011 at 3:08 pm

Hi,Excellent Article..
Can we call a webService/BPEL Process from the Java Action ?
What’s the Trade-off in terms of performance?
I want to invoke a BPEL Service,when mediator results in a Fault.



Murali December 1, 2014 at 7:46 am

I want to see your previous post i.e how you can create your own fault handling policy for your BPEL process. where can i get that.


Leave a Comment


Previous post:

Next post:

About Whitehorses
Company profile

Whitehorses website

Home page

Follow us
Blog post RSS
Comment RSS