flowable/flowable-engine · error · FlowableCdiException

No task associated. Call businessProcess.startTask() first.

Error message

No task associated. Call businessProcess.startTask() first.

What it means

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.

Source

Thrown at modules/flowable-cdi/src/main/java/org/flowable/cdi/BusinessProcess.java:510

        Execution execution = getExecution();
        if (execution != null && !(execution.getProcessInstanceId().equals(execution.getId()))) {
            return processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult();
        }
        return (ProcessInstance) execution;
    }

    // internal implementation
    // //////////////////////////////////////////////////////////

    protected void assertAssociated() {
        if (associationManager.getExecution() == null) {
            throw new FlowableCdiException("No execution associated. Call businessProcess.associateExecutionById() or businessProcess.startTask() first.");
        }
    }

    protected void assertTaskAssociated() {
        if (associationManager.getTask() == null) {
            throw new FlowableCdiException("No task associated. Call businessProcess.startTask() first.");
        }
    }

    protected Map<String, Object> getCachedVariables() {
        return associationManager.getCachedVariables();
    }

    protected Map<String, Object> getAndClearCachedVariables() {
        Map<String, Object> beanStore = getCachedVariables();
        Map<String, Object> copy = new HashMap<>(beanStore);
        beanStore.clear();
        return copy;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Call businessProcess.startTask(taskId) before completeTask() in the same conversation.
  2. Guard against double submission (disable button, idempotency check) so completeTask runs once.
  3. Check taskService task existence first; if the task is gone, treat it as already completed.

Example fix

// before
businessProcess.completeTask(); // may throw if not associated
// after
businessProcess.startTask(taskId);
businessProcess.completeTask();
Defensive patterns

Strategy: try-catch

Validate before calling

if (!businessProcess.isTaskAssociated()) {
  businessProcess.startTask(taskId);
}

Type guard

boolean taskAssociated() {
  return businessProcess.isTaskAssociated();
}

Try / catch

try {
  businessProcess.completeTask();
} catch (FlowableCdiException e) {
  // no task associated: likely double-completion; inform user
}

Prevention

When it happens

Trigger: Calling businessProcess.completeTask() in a conversation without a prior startTask(taskId); double-completing a task so the association is gone on the second call.

Common situations: Users double-clicking a 'complete' button; losing conversation scope across requests; rendering a completion form after the task already finished.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/488e5ffbf1d34321. Report an issue: GitHub.