{"record":{"id":"488e5ffbf1d34321","repo":"flowable/flowable-engine","slug":"no-task-associated-call-businessprocess-starttask","errorCode":null,"errorMessage":"No task associated. Call businessProcess.startTask() first.","messagePattern":"No task associated\\. Call businessProcess\\.startTask\\(\\) first\\.","errorType":"exception","errorClass":"FlowableCdiException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java","lineNumber":510,"sourceCode":"        Execution execution = getExecution();\n        if (execution != null && !(execution.getProcessInstanceId().equals(execution.getId()))) {\n            return processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult();\n        }\n        return (ProcessInstance) execution;\n    }\n\n    // internal implementation\n    // //////////////////////////////////////////////////////////\n\n    protected void assertAssociated() {\n        if (associationManager.getExecution() == null) {\n            throw new FlowableCdiException(\"No execution associated. Call businessProcess.associateExecutionById() or businessProcess.startTask() first.\");\n        }\n    }\n\n    protected void assertTaskAssociated() {\n        if (associationManager.getTask() == null) {\n            throw new FlowableCdiException(\"No task associated. Call businessProcess.startTask() first.\");\n        }\n    }\n\n    protected Map<String, Object> getCachedVariables() {\n        return associationManager.getCachedVariables();\n    }\n\n    protected Map<String, Object> getAndClearCachedVariables() {\n        Map<String, Object> beanStore = getCachedVariables();\n        Map<String, Object> copy = new HashMap<>(beanStore);\n        beanStore.clear();\n        return copy;\n    }\n\n}\n","sourceCodeStart":492,"sourceCodeEnd":526,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java#L492-L526","documentation":"assertTaskAssociated() requires that a Task is associated with the current CDI conversation before completeTask() can run. If startTask()/setTask() was never called (or the task already completed), it throws FlowableCdiException.","triggerScenarios":"Calling businessProcess.completeTask() in a conversation without a prior startTask(taskId); double-completing a task so the association is gone on the second call.","commonSituations":"Users double-clicking a 'complete' button; losing conversation scope across requests; rendering a completion form after the task already finished.","solutions":["Call businessProcess.startTask(taskId) before completeTask() in the same conversation.","Guard against double submission (disable button, idempotency check) so completeTask runs once.","Check taskService task existence first; if the task is gone, treat it as already completed."],"exampleFix":"// before\nbusinessProcess.completeTask(); // may throw if not associated\n// after\nbusinessProcess.startTask(taskId);\nbusinessProcess.completeTask();","handlingStrategy":"try-catch","validationCode":"if (!businessProcess.isTaskAssociated()) {\n  businessProcess.startTask(taskId);\n}","typeGuard":"boolean taskAssociated() {\n  return businessProcess.isTaskAssociated();\n}","tryCatchPattern":"try {\n  businessProcess.completeTask();\n} catch (FlowableCdiException e) {\n  // no task associated: likely double-completion; inform user\n}","preventionTips":["Guard completeTask with startTask in the same conversation","Prevent double submits with idempotency checks","Check task existence before completing"],"tags":["flowable","cdi","task","association"],"backgroundTag":"invalid-state-transition","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"}