{"record":{"id":"e31afffa5b58753a","repo":"flowable/flowable-engine","slug":"execution-executionid-doesn-t-exist-e31aff","errorCode":null,"errorMessage":"execution \" + executionId + \" doesn't exist","messagePattern":"execution \" \\+ executionId \\+ \" doesn't exist","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/HasExecutionVariableCmd.java","lineNumber":54,"sourceCode":"        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Boolean execute(CommandContext commandContext) {\n        if (executionId == null) {\n            throw new ActivitiIllegalArgumentException(\"executionId is null\");\n        }\n        if (variableName == null) {\n            throw new ActivitiIllegalArgumentException(\"variableName is null\");\n        }\n\n        ExecutionEntity execution = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(executionId);\n\n        if (execution == null) {\n            throw new ActivitiObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        boolean hasVariable = false;\n\n        if (isLocal) {\n            hasVariable = execution.hasVariableLocal(variableName);\n        } else {\n            hasVariable = execution.hasVariable(variableName);\n        }\n\n        return hasVariable;\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":68,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/HasExecutionVariableCmd.java#L36-L68","documentation":"Thrown by HasExecutionVariableCmd.execute() when findExecutionById(executionId) returns null, i.e. no execution exists with the given id. Raised as ActivitiObjectNotFoundException with Execution.class as the referenced class.","triggerScenarios":"Calling runtimeService.hasVariable(executionId, name) / hasVariableLocal with an execution id that no longer exists or never existed; the execution ended and was deleted before the check.","commonSituations":"A process instance finished before the query ran (async continuation or race), a stale execution id persisted in external storage, or a typo/copied id from another engine.","solutions":["Verify the execution id exists before the call: runtimeService.createExecutionQuery().executionId(id).singleResult() != null","Handle ActivitiObjectNotFoundException and treat it as 'process already ended'","Fix the source of the stale id (e.g. an async job that outlives its execution)"],"exampleFix":"// before\nboolean has = runtimeService.hasVariable(executionId, name);\n// after\nExecution e = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nboolean has = e != null && runtimeService.hasVariable(executionId, name);","handlingStrategy":"validation","validationCode":"boolean exists = runtimeService.createExecutionQuery().executionId(executionId).count() > 0;","typeGuard":null,"tryCatchPattern":"try { return runtimeService.hasVariable(executionId, name); } catch (ActivitiObjectNotFoundException e) { log.warn(\"execution {} gone\", executionId); return false; }","preventionTips":["Re-query executions instead of caching ids across long operations","Treat missing executions as 'process already ended' in async code","Watch for jobs outliving their process instance in async continuations"],"tags":["java","activiti","not-found","stale-reference"],"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"}