flowable/flowable-engine · error · FlowableObjectNotFoundException

task ${taskId} doesn't exist

Error message

task ${taskId} doesn't exist

What it means

GetTaskVariablesCmd loads the task entity before returning its variables. If the task service cannot find a task for the supplied taskId it throws FlowableObjectNotFoundException('task <id> doesn't exist', Task.class). Inputs are valid; the referenced task is gone or unknown.

Source

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

    protected boolean isLocal;

    public GetTaskVariablesCmd(String taskId, Collection<String> variableNames, boolean isLocal) {
        this.taskId = taskId;
        this.variableNames = variableNames;
        this.isLocal = isLocal;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId 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);
        }

        if (variableNames == null) {

            if (isLocal) {
                return task.getVariablesLocal();
            } else {
                return task.getVariables();
            }

        } else {

            if (isLocal) {
                return task.getVariablesLocal(variableNames, false);
            } else {
                return task.getVariables(variableNames, false);
            }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the task exists via cmmnTaskService.createTaskQuery().taskId(id).singleResult() before reading variables.
  2. Catch FlowableObjectNotFoundException and handle it as business 'task finished/unknown' logic.
  3. Verify you are connected to the same database/tenant where the CMMN case created the task.
  4. If the task completed, use CmmnHistoryService task variable queries instead.

Example fix

// before
Map<String, Object> vars = cmmnTaskService.getVariables(taskId);
// after
try {
    Map<String, Object> vars = cmmnTaskService.getVariables(taskId);
} catch (FlowableObjectNotFoundException e) {
    // task completed or unknown id - use history or return empty map
    Map<String, Object> vars = Collections.emptyMap();
}
Defensive patterns

Strategy: try-catch

Validate before calling

Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task == null) { return Collections.emptyMap(); }

Try / catch

try { return taskService.getVariables(taskId); } catch (FlowableObjectNotFoundException e) { // completed, deleted, or wrong engine
    return Collections.emptyMap(); }

Prevention

When it happens

Trigger: getVariables(taskId)/getVariablesLocal(taskId, ...) called with an id of a completed/deleted task, a task from another database or engine (BPMN vs CMMN), or a simply wrong/mistyped id.

Common situations: Human-task UI holding a stale id after the task was claimed and completed elsewhere; environment mismatch (prod id used against a dev engine); task purged by history cleanup jobs while the client still referenced it.

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/069e14b774953dbb. Report an issue: GitHub.