flowable/flowable-engine · error · FlowableObjectNotFoundException

task

Error message

task 

What it means

GetTaskDataObjectsCmd loads the task by id via TaskService.getTask(taskId) and throws FlowableObjectNotFoundException("task <id> doesn't exist", Task.class) when no matching task row is found, so the variables map cannot be built.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskDataObjectsCmd.java:74

    public GetTaskDataObjectsCmd(String taskId, Collection<String> variableNames, String locale, boolean withLocalizationFallback) {
        this.taskId = taskId;
        this.variableNames = variableNames;
        this.locale = locale;
        this.withLocalizationFallback = withLocalizationFallback;
    }

    @Override
    public Map<String, DataObject> execute(CommandContext commandContext) {
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is null");
        }

        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

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

        Map<String, DataObject> dataObjects = null;
        Map<String, VariableInstance> variables = null;
        if (variableNames == null) {
            variables = task.getVariableInstances();
        } else {
            variables = task.getVariableInstances(variableNames, false);
        }

        if (variables != null) {
            dataObjects = new HashMap<>(variables.size());

            for (Entry<String, VariableInstance> entry : variables.entrySet()) {
                VariableInstance variableEntity = entry.getValue();

                String localizedName = null;
                String localizedDescription = null;

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Confirm the task exists with taskService.createTaskQuery().taskId(taskId).singleResult() before fetching data objects
  2. Catch FlowableObjectNotFoundException and handle the missing-task case gracefully (re-query the task list)
  3. Verify engine/database configuration matches the environment the taskId came from

Example fix

// before
Map<String, DataObject> vars = taskService.getDataObjects(taskId); // throws
// after
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task != null) {
    Map<String, DataObject> vars = taskService.getDataObjects(taskId);
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = taskService.createTaskQuery().taskId(taskId).count() > 0;

Type guard

boolean taskExists(String taskId) {
    return taskId != null
        && taskService.createTaskQuery().taskId(taskId).count() > 0;
}

Try / catch

try {
    Map<String, DataObject> vars = taskService.getDataObjects(taskId);
} catch (FlowableObjectNotFoundException e) {
    // task no longer exists; return empty map or re-fetch
    vars = Collections.emptyMap();
}

Prevention

When it happens

Trigger: Calling taskService.getDataObjects(taskId, ...) with a taskId that does not exist in ACT_RU_TASK: deleted task, wrong engine/database, or an id from a completed-and-purged task.

Common situations: Copy-pasting ids across environments; race where the task is completed and removed between fetch and call; incorrect tenant or engine configuration pointing at another schema.

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