IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Developing EJB client applications > Handling exceptions and faults

Checking which fault occurred for a stopped invoke activity

In a well-designed process, exceptions and faults are usually handled by fault handlers. You can retrieve information about the exception or fault that occurred for an invoke activity from the activity instance.

If an activity causes a fault to occur, the fault type determines the actions that you can take to repair the activity.


Procedure

  1. List the human task activities that are in a stopped state.
    FilterOptions fo = new FilterOptions();
    fo.setSelectedAttributes("AIID");
    fo.setQueryCondition("STATE=STATE_STOPPED AND KIND=KIND_INVOKE");
    EntityResultSet result = process.queryEntities("ACTIVITY", fo, null, null);
    This action returns a query result set that contains stopped invoke activities.
  2. Read the name of the fault.
    if (result.getEntities().size() > 0)
    {
      Entity entity = (Entity) result.getEntities().get(0);
      AIID aiid = (AIID) entity.getAttributeValue("AIID");
      ActivityInstanceData activity = process.getActivityInstance(aiid);
      
      ProcessException excp = activity.getUnhandledException();
      if ( excp instanceof ApplicationFaultException )
      {
       ApplicationFaultException fault = (ApplicationFaultException)excp;
       String faultName = fault.getFaultName();
      } }

Handling exceptions and faults