{"record":{"id":"c882335b686407df","repo":"flowable/flowable-engine","slug":"cannot-find-case-definition-with-id","errorCode":null,"errorMessage":"Cannot find case definition with id ","messagePattern":"Cannot find case definition with id ","errorType":"validation","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseDefinitionCmd.java","lineNumber":67,"sourceCode":"        this.cmmnEngineConfiguration = cmmnEngineConfiguration;\n    }\n\n    protected void validateParams(String userId, String groupId, String caseDefinitionId) {\n        if (caseDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"caseDefinitionId is null\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new FlowableIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CaseDefinitionEntity caseDefinition = cmmnEngineConfiguration.getCaseDefinitionEntityManager().findById(caseDefinitionId);\n\n        if (caseDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case definition with id \" + caseDefinitionId, CaseDefinition.class);\n        }\n\n        IdentityLinkEntity identityLinkEntity = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()\n                .createScopeDefinitionIdentityLink(caseDefinition.getId(), ScopeTypes.CMMN, userId, groupId);\n        caseDefinition.getIdentityLinks().add(identityLinkEntity);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":49,"sourceCodeEnd":78,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseDefinitionCmd.java#L49-L78","documentation":"AddIdentityLinkForCaseDefinitionCmd looks up the case definition by id and throws FlowableObjectNotFoundException (with CaseDefinition.class as the object type) when the entity manager returns null — i.e. no case definition with that id exists in the CMMN repository.","triggerScenarios":"Calling cmmnRepositoryService.addIdentityLink(...) with a caseDefinitionId that was never deployed, was deleted, belongs to a different engine/database, or has a typo/wrong case.","commonSituations":"Referencing a definition id from another environment (test vs prod DB), id captured before redeployment replaced the definition, tenant mismatch so the query filters it out, or using a process-definition id on the CMMN engine.","solutions":["Verify the id exists via cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(id).singleResult() before linking","Re-query the latest deployed definition by key instead of persisting an id across environments","Check engine/tenant configuration — ensure you query the same CMMN engine the definition was deployed to"],"exampleFix":"// before\nrepositoryService.addIdentityLink(caseDefinitionId, userId, null, IdentityLinkType.CANDIDATE);\n// after\nCaseDefinition def = repositoryService.createCaseDefinitionQuery()\n    .caseDefinitionId(caseDefinitionId).singleResult();\nif (def == null) throw new IllegalStateException(\"Unknown case definition: \" + caseDefinitionId);\nrepositoryService.addIdentityLink(def.getId(), userId, null, IdentityLinkType.CANDIDATE);","handlingStrategy":"try-catch","validationCode":"CaseDefinition def = repositoryService.createCaseDefinitionQuery()\n    .caseDefinitionId(caseDefinitionId).singleResult();\nif (def == null) throw new IllegalStateException(\"Unknown case definition: \" + caseDefinitionId);","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.addIdentityLink(defId, userId, groupId, type);\n} catch (FlowableObjectNotFoundException e) {\n    log.error(\"Case definition {} not found (wrong env/deleted?)\", defId, e);\n}","preventionTips":["Verify existence with a CaseDefinitionQuery before mutating","Re-resolve ids by key/latest version per environment instead of hardcoding","Confirm same engine, database and tenant as the deployment"],"tags":["cmmn","entity-not-found","case-definition"],"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"}