{"record":{"id":"f62300ce7174c538","repo":"flowable/flowable-engine","slug":"no-execution-found-for-id-executionid","errorCode":null,"errorMessage":"No execution found for id '${executionId}'","messagePattern":"No execution found for id '(.+?)'","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java","lineNumber":47,"sourceCode":"/**\n * @author Tijs Rademakers\n */\npublic class ExecuteActivityForAdhocSubProcessCmd implements Command<Execution>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String executionId;\n    protected String activityId;\n\n    public ExecuteActivityForAdhocSubProcessCmd(String executionId, String activityId) {\n        this.executionId = executionId;\n        this.activityId = activityId;\n    }\n\n    @Override\n    public Execution execute(CommandContext commandContext) {\n        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(executionId);\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"No execution found for id '\" + executionId + \"'\", ExecutionEntity.class);\n        }\n\n        if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess adhocSubProcess)) {\n            throw new FlowableException(\"The current flow element of the requested \" + execution + \" is not an ad-hoc sub process\");\n        }\n\n        FlowNode foundNode = null;\n\n        // if sequential ordering, only one child execution can be active\n        if (adhocSubProcess.hasSequentialOrdering()) {\n            if (execution.getExecutions().size() > 0) {\n                throw new FlowableException(\"Sequential ad-hoc sub process in \" + execution + \" already has an active execution\");\n            }\n        }\n\n        for (FlowElement flowElement : adhocSubProcess.getFlowElements()) {\n            if (activityId.equals(flowElement.getId()) && flowElement instanceof FlowNode flowNode) {\n                if (flowNode.getIncomingFlows().size() == 0) {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ExecuteActivityForAdhocSubProcessCmd.java#L29-L65","documentation":"ExecuteActivityForAdhocSubProcessCmd looks up the execution by id and throws FlowableObjectNotFoundException when findById returns null, meaning no execution with the given id exists in this engine (or it was already ended/removed).","triggerScenarios":"Calling dynamicBPMN/ad-hoc-subprocess APIs such as executing an ad-hoc activity with an executionId that has completed, was deleted, belongs to another engine's database, or is simply mistyped.","commonSituations":"Stale executionId captured before process instance termination; querying the wrong tenant/engine datasource; copy-paste of a task id instead of an execution id.","solutions":["Validate the executionId with runtimeService.createExecutionQuery().executionId(id).singleResult() before invoking","Confirm the process instance is still running and the id is an execution id, not a task or process instance id from another table","Check you are connected to the correct database/tenant"],"exampleFix":"// before\nmanagementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(staleId, \"activity1\"));\n// after\nExecution exec = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (exec == null) throw new IllegalArgumentException(\"unknown execution \" + executionId);\nmanagementService.executeCommand(new ExecuteActivityForAdhocSubProcessCmd(exec.getId(), \"activity1\"));","handlingStrategy":"validation","validationCode":"Execution exec = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (exec == null) throw new IllegalArgumentException(\"unknown executionId: \" + executionId);","typeGuard":"boolean executionExists(String id) { return runtimeService.createExecutionQuery().executionId(id).count() > 0; }","tryCatchPattern":"try { ... } catch (FlowableObjectNotFoundException e) { if (e.getEntityClass() == ExecutionEntity.class) { /* refresh ids / fail gracefully */ } else throw e; }","preventionTips":["Re-fetch execution ids from a query right before use; never cache them across transactions","Distinguish execution ids from task/process-instance ids","Verify tenant/datasource consistency"],"tags":["flowable","execution-not-found","adhoc-subprocess"],"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-14T11:17:12.474Z"}