Fault Handling in Oracle SOA Suite : Advanced Concepts

This tutorial is meant to cover extensively the mechanism that we can adopt for Fault Management for a SOA Suite composite. It will deal with a fairly overall strategy for handling faults and dealing with them in various ways.

Before diving more into advanced concepts of Handling Faults let me present a small introduction covering the basics of a Service composite.

Basic Architecture of a Service Composite in Oracle SOA Suite


  1. Service components – BPEL Processes, Business Rule, Human Task, Mediator. These are used to construct a SOA composite application. A service engine corresponding to the service component is also available.
  2. Binding components – Establish connection between a SOA composite and external world.
  3. Services provide an entry point to SOA composite application.
  4. Binding defines the protocols that communicate with the service like SOAP/HTTP, JCA adapter etc.
  5. WSDL advertises capabilities of the service.
  6. References enables a SOA composite application to send messages to external services
  7. Wires enable connection between service components.

Coming to Fault Handling in a composite there are primarily two types of faults

  1. Business faults – Occurs when application executes THROW activity or an invoke receives fault as response. Fault name is specified by the BPEL process service component. This fault is caught by the fault handler using Fault name and fault variable.
  2. Runtime faults – Thrown by system. Most of these faults are provided out of the box. These faults are associated with RunTimeFaultMessage and are included in http://schemas.oracle.com/bpel/extension namespace.

Oracle SOA Suite gives us an option of configuring fault and fault actions using policies. This means that we can create policies in response to a specific type of exception. Policies are defined in a file that by default is called fault-policies.xml

Policies for fault handling consist of two main elements:

  1. The fault condition that activates the policy block—we specify what type of fault(s) the policy is relevant for. We can then apply even more finer grained policy and actions based on error codes, error messages etc.
  2. The action(s) that should be performed when the condition is satisfied. An action for an fault may be to retry it for a certain number of time at a specified interval, or to mark it in recovery for human intervention, use a custom Java code or simply to throw the fault back. If the fault is rethrown then if we have specified any explicit ‘catch’ block in our BPEL process that will be executed.

It should also be noted that fault policies need to be explicitly associated with composites, components, or references. This is done in a fault-bindings.xml file. Fault bindings link the composite, specific components in the composite, or specific references in the components on the one hand to one of the fault policies on the other.

Have a look at the diagram below to understand a mechanism to throw a fault from a service composite, identify the fault type and then take necessary action.


The following post will try and cover all aspects of what is covered in the diagram above.

Consider the following fault-policies.xml. Read the comments in the XML to understand what each of the condition, action and property is about.

<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<faultPolicy version="2.0.1" id="CompositeFaultPolicy" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<!-- Conditions can be fine grained to include Actions based on Error Codes. If a remotefault occurs check whether it is a WSDLReadingError. If yes then rethrow it else retry it."-->
<faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension" name="bpelx:remoteFault">
<action ref="ora-rethrow-fault"/>
<action ref="ora-retry"/>
<faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension" name="bpelx:bindingFault">
<action ref="java-fault-handler"/>
<faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension" name="bpelx:runtimeFault">
<action ref="java-fault-handler"/>
<!-- This Action will invoke a Custom Java Class to process Faults. Also depending upon the returnValueanother action will be invoked whic is specified by the ref attribute. This demosntrates chaining of Actions"-->
<Action id="java-fault-handler">
<javaAction className="com.beatech.faultapp.CustomFaultHandler" defaultAction="ora-human-intervention" propertySet="properties">
<returnValue value="Manual" ref="ora-human-intervention"/>
<!-- This Action will mark the instance as "Pending for Recovery" in the EM console -->
<Action id="ora-human-intervention">
<!--This is an action will bubble up the fault to the Catch Blocks-->
<Action id="ora-rethrow-fault">
<!--This action will attempt 3 retries with intervals of 120 seconds -->
<Action id="ora-retry">
<retryFailureAction ref="java-fault-handler"/>
<!--This action will cause the instance to terminate-->
<Action id="ora-terminate">
<!--Properties can be used to pass values to the Java class as a Map that can be used by the Class -->
<propertySet name="properties">
<property name="myProperty1">propertyValue1</property>
<property name="myProperty2">propertyValue2</property>
<property name="myPropertyN">propertyValueN</property>

Inside the custom Java fault handler we can also use a switch that acts on the returnValue to chain another Action.

<javaaction classname="com.beatech.faultapp.CustomFaultHandler" defaultaction="ora-rethrow">
<returnValue ref="ora-rethrow" value="Rethrow"/>
<returnvalue ref="ora-terminate" value="Abort"/>
<returnvalue ref="ora-retry" value="Retry"/>
<returnvalue ref="ora-human-intervention" value="Manual"/>

The next step will be to create a fault-bindings.xml file to simply bound the fault policy file to the composite.

<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<composite faultPolicy="CompositeFaultPolicy"/>

Finally we have to add two properties in the composite.xml to let the composite know about them

<property name=”oracle.composite.faultPolicyFile”>fault-policies.xml></property>
<property name=”oracle.composite.faultBindingFile”>fault-bindings.xml></property>

We can use different names and locations for the fault policies and fault bindings files, by setting the properties oracle.composite.faultPolicyFile and oracle.composite.faultBindingFile in the composite.xml to configure these custom files.

For example we can refer to these files even from the MDS.

<property name=”oracle.composite.faultPolicyFile”>oramds://apps/policy/fault-policies.xml></property>
<property name=”oracle.composite.faultBindingFile”>oramds://apps/policy/fault-bindings.xml></property>

Once we hit a fault in our composite that has a custom Java Action the java class CustomFaultHandler will be instantiated. Here is one example of a Java Class.

The custom Java class has to implement the interface IFaultRecoveryJavaClass that defines two methods i.e handleRetrySuccess and handleFault. The custom Java class CustomFaultHandler has access to the IFaultRecoveryContext containing information about the composite, the fault, and the policy.

If the fault is thrown by a BPEL process we can check if it’s an instanceof BPELFaultRecoveryContextImpl to get further fault details.

package com.beatech.faultapp;
import com.collaxa.cube.engine.fp.BPELFaultRecoveryContextImpl;</pre>
import com.oracle.bpel.client.config.faultpolicy.IBPELFaultRecoveryContext;
import java.util.Map;
import oracle.integration.platform.faultpolicy.IFaultRecoveryContext;
import oracle.integration.platform.faultpolicy.IFaultRecoveryJavaClass;

public class CustomFaultHandler implements IFaultRecoveryJavaClass {
public CustomFaultHandler() {

public void handleRetrySuccess(IFaultRecoveryContext iFaultRecoveryContext) {
System.out.println("Retry Success");

public String handleFault(IFaultRecoveryContext iFaultRecoveryContext) {
//Print Fault Meta Data to Console
System.out.println("****************Fault Metadata********************************");
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());
//print all properties defined in the fault-policy file
System.out.println("Properties Set for the Fault");
Map props = iFaultRecoveryContext.getProperties();
for (Object key: props.keySet())
System.out.println("Key : " + key.toString()  + " Value : " + props.get(key).toString());
//Print Fault Details to Console if it exists
System.out.println("****************Fault Details********************************");
if(iFaultRecoveryContext instanceof BPELFaultRecoveryContextImpl)
BPELFaultRecoveryContextImpl bpelCtx = (BPELFaultRecoveryContextImpl) iFaultRecoveryContext;
System.out.println("Fault: " + bpelCtx.getFault());
System.out.println("Activity: " + bpelCtx.getActivityName());
System.out.println("Composite Instance: " + bpelCtx.getCompositeInstanceId());
System.out.println("Composite Name: " + bpelCtx.getCompositeName());
//Custom Code to Log Fault to File/DB/JMS or send Emails etc.
return "Manual";

Now here is what we can do from here

  1. Log the fault/part of fault in a flat file, database or error queue in a specified enterprise format.
  2. We can even configure to send an Email to the support group for remedy and action. (Use custom Java Email code or use the UMS java/ejb APIs to do so)
  3. Return a flag with an appropriate post Action. This flag determines what action needs to be taken next

The java class would require the SOA and BPEL runtime in classpath to compile and execute.


To make sure that when the composite instances faults out and the fault-policy.xml is able to instantiate this class we have to make it available in the server’s classpath.

There are a couple of ways to do that. Here is one of the way to achieve it.

  1. Compile your Java Project and export it as a jar file (say CustomFaultHandling.jar)
  2. Go to <Middleware Home>\Oracle_SOA1\soa\modules\oracle.soa.bpel_11.1.1 directory of your Oracle SOA Suite installation.
  3. Copy the CustomFaultHandling.jar in the above directory
  4. Unjar the oracle.soa.bpel.jar and edit the MANIFEST.MF to add an entry of the above jar in the classpath.


  1. Pack the jar again and restart both the Managed and Admin Server.
  2. Another way is to drop the CustomFaultHandling.jar in the <Middleware Home>\Oracle_SOA1\soa\modules\oracle.soa.ext_11.1.1 and run Ant on the build.xml file present in the directory.

Interestingly we also have an option in the EM console to retry all faults for a composite by setting some values in custom MBeans. They are available as Advanced BPEL properties in the SOA Infra engine.

The MBean that allows recovery of faulted instances is RecoveryConfig. It has two options for retrying

  1. RecurringScheduleConfig : A recovery window may be specified (most probably off peak hours) to recover all faulted instances. Messages being recovered can be throttled by limiting the number of messages picked up on each run by specifying the maxMessageRaiseSize.
  2. StartupScheduleConfig : With this setting on all faulted instances are automatically retried when the soa server is booted up for restart.

More details on how to use RecoverConfig Mbean can be found here



There is a small lacuna though here. It is not always possible to recover automatically. Auto-recovery is subject to some conditions.

Consider the scenarios below.

  1. Scenario A: The BPEL code uses a fault-policy and a fault is handled using the “ora-human-intervention” activity, then the fault is marked as Recoverable and the instance state is set to “Running”.
  2. Scenario B: The BPEL code uses a fault-policy and a fault is caught and re-thrown using the “ora-rethrow-fault” action, then the fault is marked as Recoverable and the instance state is set to “Faulted”; provided the fault is a recoverable one (like URL was not available).

In Scenario A, the Recoverable fault CANNOT be auto-recovered using the RecoveryConfig MBean.

In Scenario B, the Recoverable fault can be auto-recovered on server startup and/or pre-scheduled recovery.

All is not lost however. The instances can still be recovered from the console though. However for most practical purposes it isn’t desirable that a huge number of composite instances that are marked for recovery for a remote fault (say end point not available) are retried automatically. It is natural that we will yearn to automate this part as well.

Here is a sample code that gets all remote faults that are marked as recoverable from the Custom Java Class and retries them.

package com.beatech.salapp;

import java.util.Hashtable;
import java.util.List;

import javax.naming.Context;

import oracle.soa.management.facade.Fault;
import oracle.soa.management.facade.FaultRecoveryActionTypeConstants;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.facade.bpel.BPELServiceEngine;
import oracle.soa.management.util.FaultFilter;

public class FaultRecovery {

private Locator locator = null;
private BPELServiceEngine mBPELServiceEngine;

public FaultRecovery() {
locator = this.getLocator();
try {
mBPELServiceEngine =
} catch (Exception e) {

public Hashtable getJndiProps() {
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "welcome123");
jndiProps.put("dedicated.connection", "true");
return jndiProps;

public Locator getLocator() {

try {
return LocatorFactory.createLocator(getJndiProps());
} catch (Exception e) {
return null;

public void recoverFaults() {
try {
System.out.println("Get All Recoverable Faults");
/* Set Search Filters like composite Name, Instance Ids, fault Names etc.
Here I am setting the setRevoverable filter to true to retrieve all Recoverable Faults.
Also I am setting filter on faultName as i want to programatically retry all remote Faults for resubmission.
FaultFilter filter = new FaultFilter();

//Get faults using defined filter
List<Fault> faultList = mBPELServiceEngine.getFaults(filter);
System.out.println("=========================Recoverable Faults==================================================");
for (Fault fault : faultList) {
System.out.println("Composite DN: " + fault.getCompositeDN().getStringDN());
System.out.println("Composite Instance ID: " + fault.getCompositeInstanceId());
System.out.println("Component Name: " + fault.getComponentName());
System.out.println("Component Instance ID: " + fault.getComponentInstanceId());
System.out.println("Activity Name: " + fault.getLabel());
System.out.println("Fault ID: " + fault.getId());
System.out.println("Fault Name: " + fault.getName());
System.out.println("Recoverable flag: " + fault.isRecoverable());
System.out.println("Fault Message: " + fault.getMessage());
// Recovering all Recoverable Faults in a single call
//mBPELServiceEngine.recoverFaults(faultList.toArray(new Fault[faultList.size()]), FaultRecoveryActionTypeConstants.ACTION_RETRY);

} catch (Exception e) {


public static void main(String[] args) {
FaultRecovery faultRecovery = new FaultRecovery();

Replace the values in the property map with the ones in your server. Remember to give the managed server port in the Provider URL. Run the Java Class and you would see that the recoverable faults are printed.


Verify the same from the console


Run the Java program again but this time uncomment the line below

//mBPELServiceEngine.recoverFaults(faultList.toArray(new Fault[faultList.size()]), FaultRecoveryActionTypeConstants.ACTION_RETRY);

This will result in all faults marked with <strong>Recovery</strong> icon to be retried. So if the remote endpoint is responding and active now the processes will complete.

There are a host of other things that we can do in this Java Class.

Using the <strong>BPELServiceEngine</strong> object we can write messages to the BPEL audit trail, inspect the current activity, and read and update the values of BPEL variables.

The following code snippet if inserted in the code will replace any process variable with a new value before retrying. (May be used in case of Binding or Business Faults)

//Get faults using defined filter
List<Fault> faultList = mBPELServiceEngine.getFaults(filter);
System.out.println("=========================Recoverable Faults ==================================================");
for (Fault fault : faultList)
System.out.println("=========================Read Process Variables =========================================");
//Get Process Instance variables from fault object
String[] variables = mBPELServiceEngine.getVariableNames(fault);
System.out.println("Process Instance Variables:");
for (int i = 0; i < variables.length; i++)
System.out.println("Variable Name: " + variables[i]);
//Get Input Variable Data from the Activity, Modify it with a new value and recover
System.out.println("=========================Replace Variable and Recover ====================================");
System.out.println("Activity Input Variable Data:");
String value =mBPELServiceEngine.getVariable(fault, "activityRequestMessage");
System.out.println("Present value: " + value);
value = value.replace("remoteFault", "Modified Value");
System.out.println("New value: " + value);

// Recover Faults one by one

The following JARS would be required in the classpath for the above Java Code




The  post discussed the different approaches and strategies for handling faults in a composite in SOA Suite. Let me conclude this article by describing a few best practices around Fault Handling.

Oracle SOA Suite Fault Handling Best Practices

  1. Create fault (catch block) for each partner link. For each partner link, have a catch block for all possible errors. Idea is not to let errors go to catchAll block.
  2. CatchAll should be kept for all errors that cannot be thought of during design time.
  3. Classify errors into various types – runtime, remote, binding, validation, Business errors etc.
  4. Notification should be setup in production, so that, errors are sent to concerned teams by E-Mail. Console need not be visited for finding out status of execution.
  5. Use Catch Block for non-partner link error.
  6. Every retry defined in fault policy causes a commit of the transaction. Dehydration will be reached and threads released.
  7. Automated recovery can be created by creating a fault table, persisting the queue and having an agent  to re-submit the job (For example writing a Timer agent to invoke the Java code we wrote to recover instances) . Can be achieved through scripts. Use only PUBLISHED API of ESB or QUEUE (AQ etc.) for re-submission. Another example would be to use WLST to change the RecoveryConfig MBean to configure recovery window to retry all faulted instances.
  8. Handle Rollback fault by providing ‘No Action’ in fault policy.
  9. Remember – Receive, OnMessage, On Alarm, Wait, CheckPoint (Activity for forcing Java thread to store its current state to Dehydration store) will cause storing of current state to dehydration store and threads will be released.
  10. Always use MDS to store fault policies and bindings to increase their reuse for multiple composites and projects.

All artifacts used for demonstration in this article can be found at this link.


17 thoughts on “Fault Handling in Oracle SOA Suite : Advanced Concepts

  1. Pingback: Fault and Business Exception Handling in Oracle BPM Suite 11g « Oracle Technologies Premier

    • Hi Venkat,

      There are so many read to resources available across many blogs and oracle documentation on how to create fault policy files. Is there a specific thing that you are struggling with?



  2. Pingback: Links | Siva's Blog

  3. Pingback: Fix Soa Error Handling Windows XP, Vista, 7, 8 [Solved]

  4. Hello Arun a question I am looking for to manipulate the BPEL instances that are generated at the level of ‘Enterprise Manager’ in the cases of ‘Human-Interventions’. With the JAVA code I want to reprocess the messages (Turning them to Throw) but from JAVA in a massive way. This solution is the one that I’m looking for, applicable from JAVA. Is posible ?


    • Hi Cesar,

      It is possible. Once you have a handle to the instance and its fault you can bulk manage instances. The fault APIs provide a mechanism to take a further action on the faulted instance.


If you have any comments, suggestions or feedback about the post, please feel free to type it here and I will do my best to address them asap

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s