flowable/flowable-engine · error · FlowableIllegalArgumentException
Cannot find case definition with id
Error message
Cannot find case definition with id
What it means
ModifyCaseInstanceStartEventSubscriptionCmd.execute() resolves the target case definition when changing a case instance's start event subscription. If the resolved newCaseDefinition is null (neither a new definition id nor the latest definition by key could be found) it throws FlowableIllegalArgumentException 'Cannot find case definition with id <id>'.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/ModifyCaseInstanceStartEventSubscriptionCmd.java:53
protected final CaseInstanceStartEventSubscriptionModificationBuilderImpl builder;
public ModifyCaseInstanceStartEventSubscriptionCmd(CaseInstanceStartEventSubscriptionModificationBuilderImpl builder) {
this.builder = builder;
}
@Override
public Void execute(CommandContext commandContext) {
CaseDefinition newCaseDefinition;
if (builder.hasNewCaseDefinitionId()) {
newCaseDefinition = getCaseDefinitionById(builder.getNewCaseDefinitionId(), commandContext);
} else {
// no explicit case definition provided, so use latest one
CaseDefinition caseDefinition = getCaseDefinitionById(builder.getCaseDefinitionId(), commandContext);
newCaseDefinition = getLatestCaseDefinitionByKey(caseDefinition.getKey(), caseDefinition.getTenantId(), commandContext);
}
if (newCaseDefinition == null) {
throw new FlowableIllegalArgumentException("Cannot find case definition with id " + (builder.hasNewCaseDefinitionId() ?
builder.getNewCaseDefinitionId() :
builder.getCaseDefinitionId()));
}
Case caze = getCase(newCaseDefinition.getId(), commandContext);
String eventDefinitionKey = caze.getStartEventType();
String startCorrelationConfiguration = getStartCorrelationConfiguration(newCaseDefinition.getId(), commandContext);
if (eventDefinitionKey != null && Objects.equals(startCorrelationConfiguration, CmmnXmlConstants.START_EVENT_CORRELATION_MANUAL)) {
String correlationKey = null;
if (builder.hasCorrelationParameterValues()) {
correlationKey = generateCorrelationConfiguration(eventDefinitionKey, builder.getTenantId(),
builder.getCorrelationParameterValues(), commandContext);
}
getEventSubscriptionService(commandContext).updateEventSubscriptionScopeDefinitionId(builder.getCaseDefinitionId(), newCaseDefinition.getId(),View on GitHub (pinned to d6d39ce1c6)
Solutions
- Verify the case definition id exists: query the CmmnRepositoryService case-definition query for the id before changing the subscription
- If relying on 'latest by key', confirm at least one deployed definition with that key still exists
- Use CaseDefinitionNotFoundException handling / FlowableIllegalArgumentException catch to surface a user-friendly message
Example fix
// before
builder.newCaseDefinitionId("def-does-not-exist").changeSubscription();
// after
CaseDefinition def = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId("correct-def-id").singleResult();
builder.newCaseDefinitionId(def.getId()).changeSubscription(); Defensive patterns
Strategy: validation
Validate before calling
CaseDefinition cd = cmmnRepositoryService.createCaseDefinitionQuery().caseDefinitionId(defId).singleResult();
if (cd == null) throw new IllegalArgumentException("Case definition not deployed: " + defId); Try / catch
try { builder.newCaseDefinitionId(defId).changeSubscription(); } catch (FlowableIllegalArgumentException e) { log.error("Case definition missing: {}", e.getMessage()); } Prevention
- Resolve ids via repository queries, never hard-code definition ids across environments
- Re-check definition existence after deployments/undeployments in automated pipelines
- Catch FlowableIllegalArgumentException around subscription changes to give user-friendly errors
When it happens
Trigger: Calling CaseInstanceStartEventSubscriptionBuilder.changeSubscription()/start() with newCaseDefinitionId pointing at a non-deployed/deleted case definition, or where getLatestCaseDefinitionByKey returns null because the latest version of the original definition no longer exists.
Common situations: Definition id from another engine/database environment (test vs prod); definition deleted via cascading delete before the subscription change; typo in definition id string; migrations that removed the latest version.
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
- Setting variable is not supported for read only delegate exe
- Can only trigger a plan item that is in the ACTIVE state
- No External Worker job found for id: ${externalJobId}
- ${workerId} does not hold a lock on the requested job
- Case instance id is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/6cbcb6f3f36a1ce9.
Report an issue: GitHub.