{"record":{"id":"190b60845198ba20","repo":"flowable/flowable-engine","slug":"cannot-associate-execution-by-id-no-execution-wit","errorCode":null,"errorMessage":"Cannot associate execution by id: no execution with id '","messagePattern":"Cannot associate execution by id: no execution with id '","errorType":"exception","errorClass":"FlowableCdiException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java","lineNumber":274,"sourceCode":"        Map<String, Object> cachedVariables = getAndClearCachedVariables();\n        cachedVariables.putAll(variables);\n        ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables);\n        if (!instance.isEnded()) {\n            setExecution(instance);\n        }\n        return instance;\n    }\n\n    /**\n     * Associate with the provided execution. This starts a unit of work.\n     *\n     * @param executionId the id of the execution to associate with.\n     * @throws FlowableCdiException if no such execution exists\n     */\n    public void associateExecutionById(String executionId) {\n        Execution execution = processEngine.getRuntimeService().createExecutionQuery().executionId(executionId).singleResult();\n        if (execution == null) {\n            throw new FlowableCdiException(\"Cannot associate execution by id: no execution with id '\" + executionId + \"' found.\");\n        }\n        associationManager.setExecution(execution);\n    }\n\n    /**\n     * returns true if an {@link Execution} is associated.\n     *\n     * @see #associateExecutionById(String)\n     */\n    public boolean isAssociated() {\n        return associationManager.getExecutionId() != null;\n    }\n\n    /**\n     * Signals the current execution, see {@link RuntimeService#trigger(String)}\n     * <p>\n     * Ends the current unit of work (flushes changes to process variables set using {@link #setVariable(String, Object)} or made on {@link BusinessProcessScoped @BusinessProcessScoped} beans).\n     *","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java#L256-L292","documentation":"associateExecutionById validates the execution id with an ExecutionQuery and throws FlowableCdiException when no execution with that id exists, refusing to associate the CDI conversation with a nonexistent execution. Called internally by startTask, setExecution, and setExecutionId.","triggerScenarios":"Passing a stale, completed, or mistyped execution/process-instance id to businessProcess.associateExecutionById(...) or businessProcess.setExecutionId(...) (the latter indirectly).","commonSituations":"Resuming a conversation whose process instance has already ended and been removed; storing the id as a String in a form/session and it changed or got truncated; calling before the process instance actually started.","solutions":["Query the execution first (runtimeService.createExecutionQuery().executionId(id).singleResult()) and handle null before associating.","Ensure the process instance is still running — completed/historic instances cannot be associated.","Fix id storage/retrieval so the exact process instance id is passed."],"exampleFix":"// before\nbusinessProcess.associateExecutionById(id); // throws if gone\n// after\nExecution e = runtimeService.createExecutionQuery().executionId(id).singleResult();\nif (e != null) {\n  businessProcess.associateExecutionById(id);\n}","handlingStrategy":"validation","validationCode":"Execution e = runtimeService.createExecutionQuery().executionId(executionId).singleResult();\nif (e == null) {\n  // skip association / recover\n}","typeGuard":"boolean executionExists(String id) {\n  return runtimeService.createExecutionQuery().executionId(id).count() > 0;\n}","tryCatchPattern":"try {\n  businessProcess.associateExecutionById(id);\n} catch (FlowableCdiException e) {\n  // execution gone: reset conversation state or notify user\n}","preventionTips":["Only associate ids of running process instances","Re-associate when restoring CDI conversations","Do not cache execution ids beyond the process lifetime"],"tags":["flowable","cdi","execution","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}