flowable/flowable-engine · error · FlowableException

Process model (id = ${processDefinitionId}) could not be fou

Error message

Process model (id = ${processDefinitionId}) could not be found for ${execution}

What it means

Thrown by IntermediateThrowCompensationEventActivityBehavior when an intermediate throwing compensation event executes and ProcessDefinitionUtil.getProcess(processDefinitionId) returns null for the execution's process definition id. It means the BPMN process model for the running execution cannot be resolved from the process definition cache/repository, so the behavior cannot look up the referenced compensation activity element.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java:84

        CommandContext commandContext = Context.getCommandContext();
        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        EventSubscriptionService eventSubscriptionService = processEngineConfiguration.getEventSubscriptionServiceConfiguration().getEventSubscriptionService();

        List<CompensateEventSubscriptionEntity> eventSubscriptions = new ArrayList<>();
        if (StringUtils.isNotEmpty(activityRef)) {
            
            // If an activity ref is provided, only that activity is compensated
            List<CompensateEventSubscriptionEntity> compensationEvents = eventSubscriptionService
                    .findCompensateEventSubscriptionsByProcessInstanceIdAndActivityId(execution.getProcessInstanceId(), activityRef);
            
            if (compensationEvents == null || compensationEvents.size() == 0) {
                // check if compensation activity was referenced directly (backwards compatibility pre 6.4.0)
                
                String processDefinitionId = execution.getProcessDefinitionId();
                Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
                if (process == null) {
                    throw new FlowableException("Process model (id = " + processDefinitionId + ") could not be found for " + execution);
                }

                String compensationActivityId = null;
                FlowElement flowElement = process.getFlowElement(activityRef, true);
                if (flowElement instanceof Activity activity) {
                    if (activity.isForCompensation()) {
                        List<Association> associations = process.findAssociationsWithTargetRefRecursive(activity.getId());
                        for (Association association : associations) {
                            FlowElement sourceElement = process.getFlowElement(association.getSourceRef(), true);
                            if (sourceElement instanceof BoundaryEvent sourceBoundaryEvent) {
                                if (sourceBoundaryEvent.getAttachedToRefId() != null) {
                                    compensationActivityId = sourceBoundaryEvent.getAttachedToRefId();
                                    break;
                                }
                            }
                        }
                    }
                }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Check that the deployment and process definition backing the running execution still exist (ACT_RE_PROCDEF / repositoryService.createProcessDefinitionQuery().processDefinitionId(id)) before or while the compensation event fires.
  2. Stop deleting deployments/process definitions that have active process instances; migrate or complete those instances first.
  3. Redeploy the process model so the definition is present in the repository and definition cache.
  4. Restart the engine/clear the definition cache so it reloads definitions from the repository after a database restore.
  5. If instances are unrecoverable, delete the stale process instances referencing the missing definition.

Example fix

// before: deleting the deployment while instances run
repositoryService.deleteDeployment(deploymentId, true);
// after: verify no running instances for definitions in the deployment first
long running = repositoryService.createProcessDefinitionQuery()
    .deploymentId(deploymentId)
    .list().stream()
    .mapToLong(pd -> runtimeService.createProcessInstanceQuery()
        .processDefinitionId(pd.getId()).count())
    .sum();
if (running == 0) {
    repositoryService.deleteDeployment(deploymentId, true);
}
Defensive patterns

Strategy: validation

Validate before calling

ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
    .processDefinitionId(execution.getProcessDefinitionId()).singleResult();
if (pd == null) {
    throw new IllegalStateException("Process definition gone while instance is running: "
        + execution.getProcessDefinitionId());
}

Type guard

boolean definitionResolvable(DelegateExecution e) {
    return repositoryService.createProcessDefinitionQuery()
        .processDefinitionId(e.getProcessDefinitionId()).count() > 0;
}

Try / catch

try {
    process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
} catch (FlowableException ex) {
    logger.error("Process model missing for {}", execution.getProcessDefinitionId(), ex);
    throw ex;
}

Prevention

When it happens

Trigger: Executing an intermediate throw compensation event (optionally with an activityRef for pre-6.4.0 backwards compatibility) when the process definition for execution.getProcessDefinitionId() is no longer resolvable, e.g. the deployment/definition was deleted while an execution was still running.

Common situations: Cascade-delete of deployments or process definitions while process instances are in flight; stale process definition cache after redeploying with a new deployment that removed old definitions; database restored/purged while long-running executions still reference old definitions; misconfigured process definition cache in cluster setups.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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