{"record":{"id":"c0cd796f873a738e","repo":"flowable/flowable-engine","slug":"cannot-find-case-instance-with-id-c0cd79","errorCode":null,"errorMessage":"Cannot find case instance with id ","messagePattern":"Cannot find case instance with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetEntityLinkChildrenWithSameRootAsCaseInstanceCmd.java","lineNumber":45,"sourceCode":"\n/**\n * @author Filip Hrisafov\n */\npublic class GetEntityLinkChildrenWithSameRootAsCaseInstanceCmd implements Command<List<EntityLink>> {\n    \n    protected String caseInstanceId;\n\n    public GetEntityLinkChildrenWithSameRootAsCaseInstanceCmd(String caseInstanceId) {\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @Override\n    public List<EntityLink> execute(CommandContext commandContext) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case instance with id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n\n        return cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()\n                .findEntityLinksWithSameRootScopeForScopeIdAndScopeType(caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":27,"sourceCodeEnd":53,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetEntityLinkChildrenWithSameRootAsCaseInstanceCmd.java#L27-L53","documentation":"GetEntityLinkChildrenWithSameRootAsCaseInstanceCmd verifies the case instance exists before querying entity links sharing the same root scope. A missing case instance raises FlowableObjectNotFoundException with the id, typed to CaseInstanceEntity.class.","triggerScenarios":"Calling cmmnRuntimeService.getEntityLinkChildrenWithSameRootAsCaseInstance(caseInstanceId) with an unknown, deleted, or wrong-engine id.","commonSituations":"Cross-referencing ids from a BPMN-only application; case data purged by history cleanup; id from a different database schema.","solutions":["Check case instance existence with a CaseInstanceQuery before the call","Confirm the id belongs to the CMMN engine and the same database","Persist the id at case start time rather than reconstructing it"],"exampleFix":"// before\nList<EntityLink> links = cmmnRuntimeService.getEntityLinkChildrenWithSameRootAsCaseInstance(id);\n// after\nCaseInstance ci = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult();\nif (ci != null) {\n    List<EntityLink> links = cmmnRuntimeService.getEntityLinkChildrenWithSameRootAsCaseInstance(id);\n}","handlingStrategy":"validation","validationCode":"CaseInstance ci = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\nboolean exists = ci != null;","typeGuard":null,"tryCatchPattern":"try { return cmmnRuntimeService.getEntityLinkChildrenWithSameRootAsCaseInstance(id); } catch (FlowableObjectNotFoundException e) { return Collections.emptyList(); }","preventionTips":["Persist the case instance id at start time and reuse it","Use the CMMN runtime service for case-related ids","Add existence checks in service methods wrapping engine calls"],"tags":["not-found","cmmn","case-instance","entity-link"],"backgroundTag":"entity-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"}