Oracle SOA Suite 11g provides administrators with a set of Purge scripts to manage the retention of SOA Composite instance data.
The scripts are specifically designed to not remove composite instances in the faulted state to ensure that business data is not discarded.

However in a development environment, a large number of faulted instances can accumulate during testing.
The following Java utility utilizes the SOA Suite Invocation API to remove all instances in the faulted state.

Note: The Utility should only be executed against composites in a Development Environment

package com.managesoa;

import javax.naming.Context;
import java.util.*;

 * ManageComposites is a commandline utility that will list and optionally delete
 * all Oracle SOA Composite instances that are in a faulted state.
 * This utilty provides an method of removing instances that are not processed
 * by the SOA Purge Scripts.
 * The utility accepts 1 of 3 different commands:
 * listFaulted - List all composites along with a count of the faulted instances for each composite.
 * removeFaulted - Remove all faulted instances for all composites
 * interactive - Processes 1 composite at a time prompting the operator for a confirmation to remove faulted instances.
 * The following 4 dedendencies must be on the classpath at runtime:
 * $FMWHOME/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar
 * $FMWHOME/oracle_common/webservices/wsclient_extended.jar
 * $FMWHOME/oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar
 * $FMWHOME/oracle_common/modules/wlthint3client.jar
 * @Author Bob Webster Mar 2014
public class ManageComposites {
 public static void main(String[] args) {

 String host = null;
 String port = null;
 String partition = null;
 String command = null;
 String userid = null;
 String password = null;
 Console consoleReader = null;
 if(args.length !=6)
     System.out.println("Usage:    java com.managesoa.ManageComposites [listFaulted | removeFaulted | Interactive] SoaPartition  wlsSoaSvrHost, wlsSoaSvcPort, userid, password");
     System.out.println("Example:  java com.managesoa.ManageComposites listFaulted default localhost 8001 weblogic password");

 command = args[0];
 partition = args[1];
 host = args[2];
 port = args[3];
 userid = args[4];
 password = args[5];
 // Connect to input keyboard if interactive mode requested.
 if(command.equals("interactive")) {
         consoleReader = System.console();    
         if(consoleReader == null) {
            System.out.println("Console not available for interactive mode. Exiting");   
 try {
     Hashtable jndiProps = new Hashtable();
     jndiProps.put(Context.PROVIDER_URL,"t3://" + host + ":" + port + "/soa-infra");
     jndiProps.put(Context.SECURITY_PRINCIPAL, userid);
     jndiProps.put(Context.SECURITY_CREDENTIALS, password);

     System.out.println("Connecting to t3://" + host + ":" + port + "/soa-infra");
     Locator locator = LocatorFactory.createLocator(jndiProps);
     // Get a list of all composites 
     CompositeFilter filter = new CompositeFilter();
     // List of composites and their instance info
     ArrayList compositeList = (ArrayList) locator.getComposites(filter, true);
     // Build a list of composites with faulted instances
     ArrayList faultedCompositeList = new ArrayList(compositeList.size());
     for(Composite c : compositeList) {
         if(c.getFaultCount() > 0)
    System.out.println("Located " + faultedCompositeList.size() + " composites with faulted instances.");
     if(faultedCompositeList.size() > 0) {
            // List and or Purge all faulted instances 
            for(Composite c : faultedCompositeList) {
                    System.out.println("Composite " +  c.getCompositeDN() + " has " + c.getFaultCount() + " faulted instances.");
                else if(command.equalsIgnoreCase("removeFaulted")) {
                        System.out.println("Removing " + c.getFaultCount() + " faulted instances for composite " + c.getCompositeDN());
                     else if(command.equalsIgnoreCase("interactive")) {
                                System.out.println("Composite " +  c.getCompositeDN() + " has " + c.getFaultCount() + " faulted instances.");
                                System.out.print("Remove faulted instances Y(es), N(o): ");
                                String inputLine = consoleReader.readLine();
                                 if(inputLine.startsWith("Y") | inputLine.startsWith("y")) {
                                       System.out.println("Removing " + c.getFaultCount() + " faulted instances for composite " + c.getCompositeDN());
                                    } else
                           else System.out.println("Invalid command, must be either listFaulted, removeFaulted or interactive");
         System.out.println("No composites with faulted instances were located.");
     } catch (Exception e) {
        System.out.println("Exception " + e.getMessage());

Building the Utility

First, to successfully compile and run the application,
you will need access to 4 libraries located in the SOA Suite installation directory.

Find the location of the Fusion Middleware Home on the local system.
Confirm your local system has the following libraries

Download the JDeveloper Application here as a zip file from GitHub

Using JDeveloper Open the ManageCompositeApp.jws file.
Right Click on the MangeCompositesUtility folder in the Application Navigator
and choose Project Properties -> Libraries and Classpath
Click the Add/Jar Directory button and navigate to the first of the four libraries above.
Repeat the process for the three remaining libraries.

Assuming the project compiles without errors,
Right click on the ManageCompositesUtility project folder and choose
Deplloy->Create Jar Deployment to Jar file
This will generate a file named ManageComposites.jar in the deploy folder under your project
Update the file located in the deploy folder to contain the correct fusion middleware home and parameters.

Running the Utility

Here is a sample script that can be used to run the utlility assuming the class file is added to a jar named ManageComposite.jar
You must update the Fusion Middleware Home path at the start of the script.
And check the URL and creditials for connecting to the SOA Managed Server
        # This script should be in the same directory as the
        ManageComposite.jar file
        # Modify the FMW_HOME to point to local location of oracle fmw

        # Check the input parameters on the last line
        # p1 - listFaulted or removeFaulted or interactive
        # p2 - SOA partition name
        # p3 - SOA Server host name
        # p4 - SOA Server port
        # p5 - SOA Admin username
        # p6 - SOA Admin password
        java -cp $CLASSPATH com.managesoa.ManageComposites interactive default localhost 7001 weblogic welcome1

The Utility has been tested on a SOA domain with 100 composites with 300,000 faulted instances..
Total time to remove instance data was approx 30 seconds.