{"record":{"id":"185f551110bf5e16","repo":"flowable/flowable-engine","slug":"execution-could-not-be-found-with-id-executionid","errorCode":null,"errorMessage":"Execution could not be found with id ${executionId}","messagePattern":"Execution could not be found with id (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java","lineNumber":294,"sourceCode":"    \n    public List<EnableActivityContainer> resolveEnableActivityContainers(ChangeActivityStateBuilderImpl changeActivityStateBuilder) {\n        List<EnableActivityContainer> enableActivityContainerList = new ArrayList<>();\n        if (!changeActivityStateBuilder.getEnableActivityIdList().isEmpty()) {\n            for (EnableActivityIdContainer enableActivityIdContainer : changeActivityStateBuilder.getEnableActivityIdList()) {\n                EnableActivityContainer enableActivityContainer = new EnableActivityContainer(enableActivityIdContainer.getActivityIds());\n                enableActivityContainerList.add(enableActivityContainer);\n            }\n        }\n        \n        return enableActivityContainerList;\n    }\n\n    protected ExecutionEntity resolveActiveExecution(String executionId, CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        ExecutionEntity execution = executionEntityManager.findById(executionId);\n\n        if (execution == null) {\n            throw new FlowableException(\"Execution could not be found with id \" + executionId);\n        }\n\n        if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) {\n            throw new FlowableException(\"Flowable 5 process definitions are not supported\");\n        }\n\n        return execution;\n    }\n\n    protected List<ExecutionEntity> resolveActiveExecutions(String processInstanceId, String activityId, CommandContext commandContext) {\n        ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);\n        ExecutionEntity processExecution = executionEntityManager.findById(processInstanceId);\n\n        if (processExecution == null) {\n            throw new FlowableException(\"Execution could not be found with id \" + processInstanceId);\n        }\n\n        if (!processExecution.isProcessInstanceType()) {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/dynamic/AbstractDynamicStateManager.java#L276-L312","documentation":"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(...).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the executionId exists at call time: runtimeService.createExecutionQuery().executionId(id).singleResult() != null.","Re-fetch the current execution ids for the process instance instead of using a cached/stale id.","Confirm you are connected to the same database/tenant where the process instance is running.","Handle the process instance having already ended — check historicProcessInstance endTime before mutating."],"exampleFix":"// before\nchangeActivityStateBuilder.moveExecutionToActivityId(staleExecutionId, \"task2\");\n// after\nExecution execution = runtimeService.createExecutionQuery().executionId(staleExecutionId).singleResult();\nif (execution != null) {\n    changeActivityStateBuilder.moveExecutionToActivityId(staleExecutionId, \"task2\");\n}","handlingStrategy":"validation","validationCode":"Execution execution = runtimeService.createExecutionQuery()\n    .executionId(executionId).singleResult();\nif (execution == null) {\n    throw new IllegalStateException(\"Execution \" + executionId + \" no longer active\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    changeActivityStateBuilder.execute();\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Execution could not be found with id\")) {\n        // refresh execution ids or handle completed process instance\n    } else {\n        throw e;\n    }\n}","preventionTips":["Re-query execution ids right before dynamic state changes instead of reusing cached ids.","Check that the process instance has not ended before changing its activity state.","Ensure all engine instances point at the same database so ids resolve."],"tags":["resource-not-found","execution","process-migration","flowable"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}