{"record":{"id":"cf34d66c305e03c5","repo":"flowable/flowable-engine","slug":"execution-executionid-doesn-t-exist-cf34d6","errorCode":null,"errorMessage":"execution \" + executionId + \" doesn't exist","messagePattern":"execution \" \\+ executionId \\+ \" doesn't exist","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/NeedsActiveExecutionCmd.java","lineNumber":48,"sourceCode":"\n    private static final long serialVersionUID = 1L;\n\n    protected String executionId;\n\n    public NeedsActiveExecutionCmd(String executionId) {\n        this.executionId = executionId;\n    }\n\n    @Override\n    public T execute(CommandContext commandContext) {\n        if (executionId == null) {\n            throw new FlowableIllegalArgumentException(\"executionId is null\");\n        }\n\n        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(executionId);\n\n        if (execution == null) {\n            throw new FlowableObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        if (execution.isSuspended()) {\n            throw new FlowableException(getSuspendedExceptionMessagePrefix() + \" a suspended \" + execution);\n        }\n\n        return execute(commandContext, execution);\n    }\n\n    /**\n     * Subclasses should implement this method. The provided {@link ExecutionEntity} is guaranteed to be active (ie. not suspended).\n     */\n    protected abstract T execute(CommandContext commandContext, ExecutionEntity execution);\n\n    /**\n     * Subclasses can override this to provide a more detailed exception message that will be thrown when the execution is suspended.\n     */\n    protected String getSuspendedExceptionMessagePrefix() {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/NeedsActiveExecutionCmd.java#L30-L66","documentation":"Flowable throws FlowableObjectNotFoundException when a command that requires an active execution cannot find the execution entity for the given executionId in the ACT_RU_EXECUTION table. The lookup happens in NeedsActiveExecutionCmd.execute before delegating to the concrete command, so any subclass command (e.g. signal, trigger, message event) on a stale or wrong execution id fails here.","triggerScenarios":"Calling a NeedsActiveExecutionCmd subclass (e.g. TriggerExecutionCmd, ExecutionSignalCmd) via RuntimeService/ExecutionService with an executionId that does not exist in the database.","commonSituations":"Using an execution id from a completed or deleted process instance; passing a processInstanceId instead of an execution id after restart; stale ids cached in client code across test runs; cluster with separate databases.","solutions":["Verify the executionId exists: query RuntimeService.createExecutionQuery().executionId(id).singleResult() before invoking the command.","Re-fetch the execution id from a fresh process instance rather than reusing ids from a previous run or a completed instance.","Confirm the app connects to the same database/schema where the process instance was started (check flowable datasource config).","Catch FlowableObjectNotFoundException and surface a 404-style message to the caller instead of a 500."],"exampleFix":"// before\nruntimeService.trigger(\"unknown-exec-id\");\n// after\nExecution execution = runtimeService.createExecutionQuery().executionId(\"unknown-exec-id\").singleResult();\nif (execution != null) {\n    runtimeService.trigger(execution.getId());\n}","handlingStrategy":"validation","validationCode":"Execution exec = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (exec == null) { throw new NotFoundException(\"Execution \" + executionId + \" not found\"); }","typeGuard":"boolean executionExists(String id) {\n    return id != null && runtimeService.createExecutionQuery().executionId(id).count() > 0;\n}","tryCatchPattern":"try {\n    runtimeService.trigger(executionId);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Execution {} no longer exists\", executionId, e);\n    throw new NotFoundException(e.getMessage());\n}","preventionTips":["Always resolve execution ids from a fresh ExecutionQuery, never cache them across sessions.","Distinguish processInstanceId from executionId in your domain model.","Verify datasource points at the intended Flowable schema in each environment.","Map FlowableObjectNotFoundException to a 404 in REST layers."],"tags":["flowable","execution","not-found","runtime-service"],"backgroundTag":"record-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"}