flowable/flowable-engine · error · ActivitiObjectNotFoundException

Cannot find process definition with id

Error message

Cannot find process definition with id 

What it means

GetIdentityLinksForProcessInstanceCmd looks up the execution (process instance) by id and returns its identity links. If no execution with the given processInstanceId exists it throws ActivitiObjectNotFoundException — note the message text mistakenly says 'process definition' but it refers to the process instance/execution.

Source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java:45

public class GetIdentityLinksForProcessInstanceCmd implements Command<List<IdentityLink>>, Serializable {

    private static final long serialVersionUID = 1L;

    protected String processInstanceId;

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

    @Override
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public List<IdentityLink> execute(CommandContext commandContext) {
        ExecutionEntity processInstance = commandContext
                .getExecutionEntityManager()
                .findExecutionById(processInstanceId);

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

        return (List) processInstance.getIdentityLinks();
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the instance is still running: runtimeService.createProcessInstanceQuery().processInstanceId(id).count() > 0
  2. For finished processes, use the history APIs (historic process instance / historic identity links) instead
  3. Catch ActivitiObjectNotFoundException and handle it as 'instance not running'
  4. Double-check the id (and tenant) being passed

Example fix

// before
runtimeService.getIdentityLinksForProcessInstance(instanceId); // may have finished
// after
if (runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).count() == 0) {
    // fall back to history or return empty
} else {
    runtimeService.getIdentityLinksForProcessInstance(instanceId);
}
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

boolean instanceIsRunning(String id) {
    return id != null && runtimeService.createProcessInstanceQuery().processInstanceId(id).count() > 0;
}

Try / catch

try {
    runtimeService.getIdentityLinksForProcessInstance(id);
} catch (ActivitiObjectNotFoundException e) {
    // instance ended or never existed: fall back to history
}

Prevention

When it happens

Trigger: Calling RuntimeService.getIdentityLinksForProcessInstance(id) with an id of a process instance that already ended, was deleted, does not exist, or a mistyped id; the runtime execution row is gone from ACT_RU_EXECUTION.

Common situations: Querying identity links after the process finished (runtime rows are removed on completion); ids copied from history endpoints; multi-tenant mismatch; typo'd instance id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/9a992f029839885b. Report an issue: GitHub.