flowable/flowable-engine · error · FlowableObjectNotFoundException

Cannot find case definition with id

Error message

Cannot find case definition with id 

What it means

Thrown by GetIdentityLinksForCaseDefinitionCmd when the CMMN engine cannot load a CaseDefinition with the supplied id. The command looks up the case definition via the CaseDefinitionEntityManager and throws FlowableObjectNotFoundException when findById returns null. This is a caller-supplied identifier problem: the referenced case definition does not exist in the engine's repository.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetIdentityLinksForCaseDefinitionCmd.java:47

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

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

    public GetIdentityLinksForCaseDefinitionCmd(String caseDefinitionId) {
        this.caseDefinitionId = caseDefinitionId;
    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    @Override
    public List<IdentityLink> execute(CommandContext commandContext) {
        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        CaseDefinitionEntity caseDefinition = cmmnEngineConfiguration.getCaseDefinitionEntityManager().findById(caseDefinitionId);

        if (caseDefinition == null) {
            throw new FlowableObjectNotFoundException("Cannot find case definition with id " + caseDefinitionId, CaseDefinition.class);
        }

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

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the id exists: run a CaseDefinitionQuery (repositoryService.createCaseDefinitionQuery().caseDefinitionId(id).singleResult()) or list all definitions and use a valid id.
  2. Use the latest deployed version: look up by key with .latestVersion() and take its id instead of a stored one.
  3. Check you are connected to the same database/schema/environment where the definition was deployed.
  4. If the definition was deleted, redeploy the CMMN model and retry with the new id.

Example fix

// before
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseDefinition("myCaseDef-1");
// after
CaseDefinition def = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionKey("myCaseDef").latestVersion().singleResult();
List<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseDefinition(def.getId());
Defensive patterns

Strategy: validation

Validate before calling

CaseDefinition def = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(caseDefId).singleResult();
if (def == null) throw new IllegalArgumentException("Unknown case definition id: " + caseDefId);

Type guard

boolean caseDefinitionExists(String id) {
    return cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(id).count() > 0;
}

Try / catch

try {
    links = cmmnRuntimeService.getIdentityLinksForCaseDefinition(caseDefId);
} catch (FlowableObjectNotFoundException e) {
    log.warn("Case definition {} not found", caseDefId);
    links = Collections.emptyList();
}

Prevention

When it happens

Trigger: Calling RuntimeService/TaskService identity-link APIs (e.g. CmmnRuntimeService.getIdentityLinksForCaseDefinition) with an id that was never deployed, was deployed to a different database/tenant, or was deleted by an earlier undeploy/cascade delete.

Common situations: Hard-coded case definition ids in tests or scripts; querying identity links after a redeploy changed the definition id; pointing a client at the wrong database or schema so the definition is absent; stale ids cached in an external system after cleanup.

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