flowable/flowable-engine · error · FlowableException

Execution could not be found with id

Error message

Execution could not be found with id ${executionId}

What it means

AbstractDynamicStateManager.resolveActiveExecution loads an ExecutionEntity by id via executionEntityManager.findById(executionId); when no execution is found it throws FlowableException('Execution could not be found with id ...'). The dynamic state change (process instance migration / change activity state) targets an execution that does not exist in the runtime tables. resolveActiveExecution is called by execution(...).

Solutions

  1. Verify the executionId exists at call time: runtimeService.createExecutionQuery().executionId(id).singleResult() != null.
  2. Re-fetch the current execution ids for the process instance instead of using a cached/stale id.
  3. Confirm you are connected to the same database/tenant where the process instance is running.
  4. Handle the process instance having already ended — check historicProcessInstance endTime before mutating.

Example fix

// before
changeActivityStateBuilder.moveExecutionToActivityId(staleExecutionId, "task2");
// after
Execution execution = runtimeService.createExecutionQuery().executionId(staleExecutionId).singleResult();
if (execution != null) {
    changeActivityStateBuilder.moveExecutionToActivityId(staleExecutionId, "task2");
}
Defensive patterns

Strategy: validation

Validate before calling

Execution execution = runtimeService.createExecutionQuery()
    .executionId(executionId).singleResult();
if (execution == null) {
    throw new IllegalStateException("Execution " + executionId + " no longer active");
}

Try / catch

try {
    changeActivityStateBuilder.execute();
} catch (FlowableException e) {
    if (e.getMessage().startsWith("Execution could not be found with id")) {
        // refresh execution ids or handle completed process instance
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling runtimeService.createChangeActivityStateBuilder()... / process instance migration operations with an executionId that does not resolve (AbstractDynamicStateManager.java:294) — wrong id, execution already ended, or different database/tenant.

Common situations: Stale executionId captured before the process instance completed; ids passed from another process engine/datasource; concurrent termination deleting the execution before the dynamic state change runs; typo or truncated id.

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/185f551110bf5e16. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java:294

    
    public List<EnableActivityContainer> resolveEnableActivityContainers(ChangeActivityStateBuilderImpl changeActivityStateBuilder) {
        List<EnableActivityContainer> enableActivityContainerList = new ArrayList<>();
        if (!changeActivityStateBuilder.getEnableActivityIdList().isEmpty()) {
            for (EnableActivityIdContainer enableActivityIdContainer : changeActivityStateBuilder.getEnableActivityIdList()) {
                EnableActivityContainer enableActivityContainer = new EnableActivityContainer(enableActivityIdContainer.getActivityIds());
                enableActivityContainerList.add(enableActivityContainer);
            }
        }
        
        return enableActivityContainerList;
    }

    protected ExecutionEntity resolveActiveExecution(String executionId, CommandContext commandContext) {
        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);
        ExecutionEntity execution = executionEntityManager.findById(executionId);

        if (execution == null) {
            throw new FlowableException("Execution could not be found with id " + executionId);
        }

        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) {
            throw new FlowableException("Flowable 5 process definitions are not supported");
        }

        return execution;
    }

    protected List<ExecutionEntity> resolveActiveExecutions(String processInstanceId, String activityId, CommandContext commandContext) {
        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);
        ExecutionEntity processExecution = executionEntityManager.findById(processInstanceId);

        if (processExecution == null) {
            throw new FlowableException("Execution could not be found with id " + processInstanceId);
        }

        if (!processExecution.isProcessInstanceType()) {

View on GitHub (pinned to d6d39ce1c6)