flowable/flowable-engine · error · FlowableObjectNotFoundException

task ${taskId} doesn't exist

Error message

task ${taskId} doesn't exist

What it means

After validating inputs, GetTaskVariableInstanceCmd looks up the task via the task service. If no task with the given taskId exists (it was completed, deleted, or the id is wrong), it throws FlowableObjectNotFoundException('task <id> doesn't exist', Task.class). The id is syntactically fine but points at no existing CMMN task entity.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetTaskVariableInstanceCmd.java:55

        this.taskId = taskId;
        this.variableName = variableName;
        this.isLocal = isLocal;
    }

    @Override
    public VariableInstance execute(CommandContext commandContext) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is null");
        }
        if (variableName == null) {
            throw new FlowableIllegalArgumentException("variableName is null");
        }

        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

        if (task == null) {
            throw new FlowableObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
        }

        VariableInstance variableEntity;

        if (isLocal) {
            variableEntity = task.getVariableInstanceLocal(variableName, false);
        } else {
            variableEntity = task.getVariableInstance(variableName, false);
        }

        return variableEntity;
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the taskId is current: re-query cmmnTaskService.createTaskQuery().taskId(id).singleResult() before fetching variables.
  2. Check the engine/database configuration points at the same datasource the task was created in.
  3. Wrap the call in try/catch for FlowableObjectNotFoundException and treat it as task-not-found rather than a bug.
  4. If the task was completed, read variables from history services (e.g. history query APIs) instead of the runtime task.

Example fix

// before
VariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName);
// after
Task task = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();
if (task == null) {
    // task finished or wrong id - fall back to history or abort
    return null;
}
VariableInstance vi = cmmnTaskService.getVariableInstance(taskId, varName);
Defensive patterns

Strategy: try-catch

Validate before calling

Task t = taskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) { /* not found: skip or use history */ }

Try / catch

try { return taskService.getVariableInstance(taskId, name); } catch (FlowableObjectNotFoundException e) { log.info("Task {} not found, may be completed", taskId); return null; }

Prevention

When it happens

Trigger: Calling getVariableInstance/getVariableInstanceLocal with a taskId for a task that has been completed and removed, deleted via taskService.deleteTask, or never existed (wrong id, wrong engine/database).

Common situations: Stale task id cached in a client after task completion; querying a different database/schema than the one the case ran in; deleted case instance whose tasks were removed; id copied from a BPMN task used against the CMMN engine.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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