flowable/flowable-engine · error · FlowableException

Error while handling compensation event " + eventSubscriptio

Error message

Error while handling compensation event " + eventSubscription

What it means

Flowable's CompensationEventHandler processes compensation events (used by transactional subprocesses and compensation boundary events). This error wraps any unexpected exception thrown while executing a compensation, preserving the original exception as the cause. It indicates the compensation logic failed mid-flight, e.g. while resolving the flow element or planning the compensation continuation.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/CompensationEventHandler.java:114

                                    if (targetActivity.isForCompensation()) {
                                        compensationActivity = targetActivity;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                
                if (compensationActivity != null) {
                    flowElement = compensationActivity;
                }
                
                compensatingExecution.setCurrentFlowElement(flowElement);
                CommandContextUtil.getAgenda().planContinueProcessInCompensation(compensatingExecution);

            } catch (Exception e) {
                throw new FlowableException("Error while handling compensation event " + eventSubscription, e);
            }

        }
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Read the chained cause (e.getCause()) of the FlowableException; it contains the real failure.
  2. Verify the deployed BPMN XML still contains the compensation boundary event / event subprocess referenced by the event subscription.
  3. Clear the process definition cache or redeploy the process definition if the model was changed after instances were started.
  4. Check ACT_RU_EXECUTION / ACT_RU_EVENT_SUBSCR rows for consistency; remove orphaned subscriptions if the process instance is already ended.
  5. Upgrade Flowable or open an issue with the cause stack trace if the state is valid — this is often an engine bug.

Example fix

// before
} catch (Exception e) {
    // swallowing details, only top message visible
}
// after
try {
    // handle compensation event
} catch (FlowableException e) {
    LOGGER.error("Compensation failed for subscription {}: {}", eventSubscription.getId(), e.getCause(), e);
    throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

EventSubscription sub = runtimeService.createEventSubscriptionQuery().subscriptionId(id).singleResult();
if (sub == null || sub.getExecutionId() == null) throw new IllegalStateException("No valid compensation subscription: " + id);

Try / catch

try {
    runtimeService.signalEventReceived(compensationSignal, subscriptionId);
} catch (FlowableException e) {
    LOGGER.error("Compensation handling failed for {}: cause={}", subscriptionId, e.getCause(), e);
    throw new CompensationFailedException(subscriptionId, e.getCause());
}

Prevention

When it happens

Trigger: Calling runtimeService.signalEventReceived / triggering a compensation event subscription where the compensating execution's current flow element lookup or planContinueProcessInCompensation throws (missing BPMN element, corrupted execution state, exception in an underlying command).

Common situations: BPMN model changed after process instances were deployed (stale process definition cache), execution pointing to a removed compensation boundary event, database inconsistency after a failed migration, bugs in custom FlowableCommandContext listeners.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/c3025c7662e5e136. Report an issue: GitHub.