{"record":{"id":"abacb4ef75caa084","repo":"flowable/flowable-engine","slug":"cannot-find-case-instance-with-id-abacb4","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/GetEntityLinkParentsForCaseInstanceCmd.java","lineNumber":48,"sourceCode":" * @author Javier Casal\n */\npublic class GetEntityLinkParentsForCaseInstanceCmd implements Command<List<EntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String caseInstanceId;\n\n    public GetEntityLinkParentsForCaseInstanceCmd(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                .findEntityLinksByReferenceScopeIdAndType(caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetEntityLinkParentsForCaseInstanceCmd.java#L30-L56","documentation":"GetEntityLinkParentsForCaseInstanceCmd loads the case instance before returning parent entity links referenced by this scope. If the case instance cannot be found it throws FlowableObjectNotFoundException including the id, typed to CaseInstanceEntity.class.","triggerScenarios":"Calling cmmnRuntimeService.getEntityLinkParentsForCaseInstance(caseInstanceId) with an id that matches no live case instance row.","commonSituations":"Case instance terminated and removed; using an entity-link scope id that is not a case instance id; environment mismatch between saved id and current database.","solutions":["Validate the id with cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id)","Use the correct scope id for the call (case instance id)","Guard cleanup jobs so ids referenced by callers are not purged prematurely"],"exampleFix":"// before\nList<EntityLink> parents = cmmnRuntimeService.getEntityLinkParentsForCaseInstance(caseInstanceId);\n// after\nif (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0) {\n    List<EntityLink> parents = cmmnRuntimeService.getEntityLinkParentsForCaseInstance(caseInstanceId);\n}","handlingStrategy":"validation","validationCode":"boolean exists = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0;","typeGuard":null,"tryCatchPattern":"try { return cmmnRuntimeService.getEntityLinkParentsForCaseInstance(id); } catch (FlowableObjectNotFoundException e) { return Collections.emptyList(); }","preventionTips":["Check the case instance is still running before querying parents","Ensure cleanup jobs do not purge cases still referenced by clients","Validate scope ids refer to case instances, not tasks or plan items"],"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"}