flowable/flowable-engine · error · FlowableException
Cannot get process definition for id for
Error message
Cannot get process definition for id for
What it means
During execution entity initialization/ensureProcessDefinitionInitialized, Flowable resolves the execution's processDefinitionId through ProcessDefinitionUtil.getProcessDefinition(). If no ProcessDefinition is found for that id, the entity cannot populate its processDefinitionKey/Name/Version/Category fields and throws this FlowableException. This means the process definition cache and database contain no definition with the stored id.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/ExecutionEntityImpl.java:1535
if (CommandContextUtil.getHistoryManager().isHistoryLevelAtLeast(HistoryLevel.FULL)) {
ActivityInstanceEntity unfinishedActivityInstance = CommandContextUtil.getActivityInstanceEntityManager()
.findUnfinishedActivityInstance(sourceExecution);
if (unfinishedActivityInstance != null) {
activityInstanceId = unfinishedActivityInstance.getId();
}
}
return activityInstanceId;
}
protected void resolveProcessDefinitionInfo() {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
if (processEngineConfiguration == null) {
// We are outside of a command context so do not try to resolve anything
return;
}
ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId, false, processEngineConfiguration);
if (processDefinition == null) {
throw new FlowableException("Cannot get process definition for id " + processDefinitionId + " for " + this);
}
this.processDefinitionKey = processDefinition.getKey();
this.processDefinitionName = processDefinition.getName();
this.processDefinitionVersion = processDefinition.getVersion();
this.processDefinitionCategory = processDefinition.getCategory();
this.deploymentId = processDefinition.getDeploymentId();
}
// toString /////////////////////////////////////////////////////////////////
@Override
public String toString() {
StringBuilder strb;
if (isProcessInstanceType()) {
strb = new StringBuilder("ProcessInstance[" + getId() + "] - definition '" + getProcessDefinitionId() + "'");
} else {
strb = new StringBuilder();View on GitHub (pinned to d6d39ce1c6)
Solutions
- Check ACT_RE_PROCDEF for the id in the message; if missing, redeploy the definition (repositoryService.createDeployment().addClasspathResource(...).deploy()) so instances can resolve it.
- Do not delete deployments with running instances: use cascade=false checks or first complete/migrate the instances, then delete the deployment.
- Fix corrupted ACT_RU_EXECUTION.PROC_DEF_ID_ values to an existing definition id (or terminate the affected instances).
- When copying data between environments, copy the process-definition (repository) tables together with runtime tables, and keep version ids consistent.
Example fix
// before: deleting a deployment while instances run
repositoryService.deleteDeployment(deploymentId);
// after: only delete when no instances remain
long count = runtimeService.createProcessInstanceQuery()
.processDefinitionId(procDefId).count();
if (count == 0) {
repositoryService.deleteDeployment(deploymentId);
} Defensive patterns
Strategy: validation
Validate before calling
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()
.processDefinitionId(procDefId).singleResult();
if (pd == null) {
throw new IllegalStateException("Unknown process definition: " + procDefId);
} Try / catch
try {
entity.ensureProcessDefinitionInitialized();
} catch (FlowableException e) {
if (e.getMessage().startsWith("Cannot get process definition")) {
// redeploy or re-map definition before continuing
} else { throw e; }
} Prevention
- Never delete deployments with running process instances of that definition.
- Copy repository tables together with runtime tables between environments.
- Query process instances by definition key (not version id) when re-deploying new versions.
When it happens
Trigger: An execution references a processDefinitionId that no longer exists (definition deleted or deployment removed while an old process instance still runs); calling entity initialization outside a command context is handled earlier (returns early), so this throw happens when getProcessDefinition returns null for a stale/unknown id; manually corrupted ACT_RU_EXECUTION rows with wrong proc_def_id_; migrating data between databases/case-insensitive mismatch.
Common situations: Deleting a deployment or app version while process instances of that version are still running; restoring a runtime DB from backup against a newer/older process definitions DB; copying runtime tables to a different environment without the corresponding ACT_RE_PROCDEF rows.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- No deployed process definition found for key '{processDefini
- no processes deployed with key '" + processDefinitionKey + "
- Could not find a resource with id '<resourceName>' in deploy
- <e.getMessage()>
- Could not find an app deployment with id '<deploymentId>
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/ebb8ffff63b5e32f.
Report an issue: GitHub.