flowable/flowable-engine · error · FlowableObjectNotFoundException

Cannot find task with id ${taskId}

Error message

Cannot find task with id ${taskId}

What it means

FlowableObjectNotFoundException thrown by ActivateTaskCmd.execute when the TaskService lookup getTask(taskId) returns null. The task id was provided but no TaskEntity exists with that id in the runtime task tables, so the command cannot activate it.

Source

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

    protected String userId;

    public ActivateTaskCmd(String taskId, String userId) {
        this.taskId = taskId;
        this.userId = userId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("taskId is null");
        }

        TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);

        if (task == null) {
            throw new FlowableObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
        }

        if (task.isDeleted()) {
            throw new FlowableException("Task " + taskId + " is already deleted");
        }

        if (!task.isSuspended()) {
            throw new FlowableException("Task " + taskId + " is not suspended, so can't be activated");
        }
        
        Clock clock = cmmnEngineConfiguration.getClock();
        Date updateTime = clock.getCurrentTime();
        task.setSuspendedTime(null);
        task.setSuspendedBy(null);
        if (task.getInProgressStartTime() != null) {
            task.setState(Task.IN_PROGRESS);
        } else if (task.getClaimTime() != null) {
            task.setState(Task.CLAIMED);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Query taskService.createTaskQuery().taskId(id).singleResult() first to confirm the task exists and is suspended
  2. If the task is gone, treat the activation as obsolete and skip/log rather than retry
  3. Verify the id against the Flowable admin UI or ACT_RU_TASK table
  4. Confirm you are connected to the same database/engine where the task was created

Example fix

// before
cmmnTaskService.activateTask(taskId); // may throw not-found
// after
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (task != null && task.isSuspended()) {
    cmmnTaskService.activateTask(taskId);
} else {
    logger.info("Task {} missing or not suspended; skipping activation", taskId);
}
Defensive patterns

Strategy: validation

Validate before calling

Task t = taskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) throw new IllegalStateException("Task " + taskId + " does not exist");

Try / catch

try { cmmnTaskService.activateTask(taskId); }
catch (FlowableObjectNotFoundException e) { log.info("Task {} not found; likely already completed", taskId); }

Prevention

When it happens

Trigger: Activating a task whose id was deleted (task completed or case terminated); using a stale id cached from a previous query; id from another engine/database (BPMN vs CMMN task tables); typo or truncated id.

Common situations: After case completion the runtime task rows are removed and old ids 404; retrying an activation job with an old id; environment mismatch (test id used against prod database).

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