flowable/flowable-engine · error · FlowableObjectNotFoundException

Could not find task entity for id

Error message

Could not find task entity for id 

What it means

Thrown by CMMN's CompleteTaskCmd when no TaskEntity exists in the task service for the given taskId. The CMMN engine requires an existing standalone (non-process) task to complete; a missing task means the id is wrong, the task was already completed/deleted, or the task belongs to a different engine/database. This is a FlowableObjectNotFoundException carrying TaskEntity.class as the entity type.

Source

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

    
    public CompleteTaskCmd(String taskId, String userId, Map<String, Object> variables, Map<String, Object> variablesLocal,
            Map<String, Object> transientVariables, Map<String, Object> transientVariablesLocal) {
        
        this(taskId, variables, variablesLocal, transientVariables, transientVariablesLocal);
        this.userId = userId;
    }
    
    @Override
    public Void execute(CommandContext commandContext) {
        
        if (taskId == null) {
            throw new FlowableIllegalArgumentException("Null task id");
        }
        
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        TaskEntity taskEntity = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);
        if (taskEntity == null) {
            throw new FlowableObjectNotFoundException("Could not find task entity for id " + taskId, TaskEntity.class);
        }
        
        if (StringUtils.isNotEmpty(taskEntity.getProcessInstanceId())) {
            throw new FlowableException(taskEntity + " is created by the process engine and should be completed via the process engine API");
        }
        
        String planItemInstanceId = taskEntity.getSubScopeId();
        PlanItemInstanceEntity planItemInstanceEntity = null;
        if (planItemInstanceId != null) {
            planItemInstanceEntity = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(planItemInstanceId);
            if (planItemInstanceEntity == null) {
                throw new FlowableException("Could not find plan item instance for " + taskEntity);
            }
        }
        
        if (variables != null) {
            taskEntity.setVariables(variables);
        }

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the taskId exists before completing, e.g. taskService.createTaskQuery().taskId(id).singleResult() != null.
  2. If the task was created by the BPMN engine, complete it via the process engine's TaskService (RuntimeService/TaskService.complete) instead.
  3. Check you are connected to the correct database/schema/tenant where the task was created.
  4. Ensure the task was not already completed in a concurrent step; fetch it fresh in the same transaction.

Example fix

// before
cmmnTaskService.completeTask(taskId);
// after
guard: org.flowable.task.api.Task t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) throw new IllegalStateException("Task " + taskId + " does not exist (already completed or wrong engine?)");
cmmnTaskService.completeTask(taskId);
Defensive patterns

Strategy: validation

Validate before calling

org.flowable.task.api.Task t = cmmnTaskService.createTaskQuery().taskId(taskId).singleResult();
if (t == null) {
    throw new IllegalStateException("No CMMN task with id " + taskId);
}
cmmnTaskService.completeTask(taskId);

Prevention

When it happens

Trigger: Calling CmmnTaskService.completeTask(taskId) (or an equivalent CompleteTaskCmd) with a taskId that does not exist: typo, task already completed and deleted, task from the BPMN process engine, or wrong tenant/database in a multi-datasource setup.

Common situations: Reusing a stale task id after the case task was completed; completing a process-engine task via the CMMN API; querying a different database/schema than the one holding the task; copying ids from a test fixture without seeding them.

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