flowable/flowable-engine · error · FlowableObjectNotFoundException

Cannot find process instance with id

Error message

Cannot find process instance with id ${processInstanceId}

What it means

GetEntityLinkChildrenWithSameRootAsProcessInstanceCmd first verifies the process instance exists via ExecutionEntityManager.findById. A null lookup triggers FlowableObjectNotFoundException because same-root entity link queries require a live BPMN process instance as the scope.

Solutions

  1. Confirm the instance is still running via runtimeService.createProcessInstanceQuery().processInstanceId(id).count() before the call.
  2. For completed instances, switch to history-based entity link retrieval via HistoryService.
  3. Verify the id is a process instance id (not an execution or case id).
  4. Check datasource/engine configuration for multi-deployment setups.

Example fix

// before
runtimeService.getEntityLinkChildrenForProcessInstanceWithSameRootAs(pid);
// after
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(pid).singleResult();
if (pi != null) {
    runtimeService.getEntityLinkChildrenForProcessInstanceWithSameRootAs(pid);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = runtimeService.createProcessInstanceQuery()
    .processInstanceId(processInstanceId).count() > 0;

Try / catch

try {
    runtimeService.getEntityLinkChildrenForProcessInstanceWithSameRootAs(id);
} catch (FlowableObjectNotFoundException e) {
    // instance gone: use history data
}

Prevention

When it happens

Trigger: Calling RuntimeService.getEntityLinkChildrenForProcessInstanceWithSameRootAs(processInstanceId) (this command) with an unknown or already-completed process instance id.

Common situations: Instance completed and cleaned before the query; copy/paste of ids across environments; using the task id or execution id instead of the process instance id; wrong tenant/engine datasource.

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

Appendix: source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetEntityLinkChildrenWithSameRootAsProcessInstanceCmd.java:44

/**
 * @author Filip Hrisafov
 */
public class GetEntityLinkChildrenWithSameRootAsProcessInstanceCmd implements Command<List<EntityLink>> {

    protected String processInstanceId;

    public GetEntityLinkChildrenWithSameRootAsProcessInstanceCmd(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    @Override
    public List<EntityLink> execute(CommandContext commandContext) {
        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
        ExecutionEntity processInstance = processEngineConfiguration.getExecutionEntityManager().findById(processInstanceId);

        if (processInstance == null) {
            throw new FlowableObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
        }

        return processEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()
                .findEntityLinksWithSameRootScopeForScopeIdAndScopeType(processInstanceId, ScopeTypes.BPMN, EntityLinkType.CHILD);
    }

}

View on GitHub (pinned to d6d39ce1c6)