flowable/flowable-engine · error · ActivitiObjectNotFoundException

Cannot find process definition with id

Error message

Cannot find process definition with id 

What it means

GetIdentityLinksForProcessDefinitionCmd loads the process definition by id from the process definition entity manager. When no definition with that id exists it throws ActivitiObjectNotFoundException including the id and ProcessDefinition.class.

Source

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

 */
public class GetIdentityLinksForProcessDefinitionCmd implements Command<List<IdentityLink>>, Serializable {

    private static final long serialVersionUID = 1L;
    protected String processDefinitionId;

    public GetIdentityLinksForProcessDefinitionCmd(String processDefinitionId) {
        this.processDefinitionId = processDefinitionId;
    }

    @Override
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public List<IdentityLink> execute(CommandContext commandContext) {
        ProcessDefinitionEntity processDefinition = commandContext
                .getProcessDefinitionEntityManager()
                .findProcessDefinitionById(processDefinitionId);

        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
        }

        List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
        return identityLinks;
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Resolve the correct id with repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult() and use its getId()
  2. Catch ActivitiObjectNotFoundException and return a friendly 'definition not found' response
  3. Check ACT_RE_PROCDEF (respecting tenant) to confirm the id exists
  4. Verify you are passing the definition id, not the deployment id or key

Example fix

// before
repoService.getIdentityLinksForProcessDefinition("myProcess"); // key, not id
// after
ProcessDefinition pd = repoService.createProcessDefinitionQuery()
    .processDefinitionKey("myProcess").latestVersion().singleResult();
if (pd != null) repoService.getIdentityLinksForProcessDefinition(pd.getId());
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = repositoryService.createProcessDefinitionQuery()
    .processDefinitionId(processDefinitionId).count() > 0;

Type guard

boolean definitionExists(String id) {
    return id != null && repositoryService.createProcessDefinitionQuery().processDefinitionId(id).count() > 0;
}

Try / catch

try {
    repositoryService.getIdentityLinksForProcessDefinition(id);
} catch (ActivitiObjectNotFoundException e) {
    // map to 404 with the definition id
}

Prevention

When it happens

Trigger: Calling RepositoryService.getIdentityLinksForProcessDefinition(id) with an id that is not in ACT_RE_PROCDEF — mistyped id, wrong tenant, definition deleted by cascading deployment delete, or passing a deployment id / key instead of the definition id.

Common situations: Confusing process definition key with id; environment mismatch (id from dev used in prod); definitions removed after deployment cleanup; stale cached ids in client code.

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