{"record":{"id":"9a992f029839885b","repo":"flowable/flowable-engine","slug":"cannot-find-process-definition-with-id-9a992f","errorCode":null,"errorMessage":"Cannot find process definition with id ","messagePattern":"Cannot find process definition with id ","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java","lineNumber":45,"sourceCode":"public class GetIdentityLinksForProcessInstanceCmd implements Command<List<IdentityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String processInstanceId;\n\n    public GetIdentityLinksForProcessInstanceCmd(String processInstanceId) {\n        this.processInstanceId = processInstanceId;\n    }\n\n    @Override\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    public List<IdentityLink> execute(CommandContext commandContext) {\n        ExecutionEntity processInstance = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(processInstanceId);\n\n        if (processInstance == null) {\n            throw new ActivitiObjectNotFoundException(\"Cannot find process definition with id \" + processInstanceId, ExecutionEntity.class);\n        }\n\n        return (List) processInstance.getIdentityLinks();\n    }\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":52,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java#L27-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the instance is still running: runtimeService.createProcessInstanceQuery().processInstanceId(id).count() > 0","For finished processes, use the history APIs (historic process instance / historic identity links) instead","Catch ActivitiObjectNotFoundException and handle it as 'instance not running'","Double-check the id (and tenant) being passed"],"exampleFix":"// before\nruntimeService.getIdentityLinksForProcessInstance(instanceId); // may have finished\n// after\nif (runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).count() == 0) {\n    // fall back to history or return empty\n} else {\n    runtimeService.getIdentityLinksForProcessInstance(instanceId);\n}","handlingStrategy":"validation","validationCode":"boolean running = runtimeService.createProcessInstanceQuery()\n    .processInstanceId(processInstanceId).count() > 0;","typeGuard":"boolean instanceIsRunning(String id) {\n    return id != null && runtimeService.createProcessInstanceQuery().processInstanceId(id).count() > 0;\n}","tryCatchPattern":"try {\n    runtimeService.getIdentityLinksForProcessInstance(id);\n} catch (ActivitiObjectNotFoundException e) {\n    // instance ended or never existed: fall back to history\n}","preventionTips":["Check the instance is still running before runtime queries; finished instances are removed from runtime tables","Use history APIs for completed instances","Keep ids in typed variables to avoid mixing task/execution/instance ids"],"tags":["flowable","activiti","not-found","process-instance","identity-links"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}