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

  1. Check ACT_RE_PROCDEF for the id in the message; if missing, redeploy the definition (repositoryService.createDeployment().addClasspathResource(...).deploy()) so instances can resolve it.
  2. Do not delete deployments with running instances: use cascade=false checks or first complete/migrate the instances, then delete the deployment.
  3. Fix corrupted ACT_RU_EXECUTION.PROC_DEF_ID_ values to an existing definition id (or terminate the affected instances).
  4. 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

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


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/ebb8ffff63b5e32f. Report an issue: GitHub.