{"record":{"id":"ebb8ffff63b5e32f","repo":"flowable/flowable-engine","slug":"cannot-get-process-definition-for-id-for","errorCode":null,"errorMessage":"Cannot get process definition for id  for ","messagePattern":"Cannot get process definition for id  for ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/ExecutionEntityImpl.java","lineNumber":1535,"sourceCode":"        if (CommandContextUtil.getHistoryManager().isHistoryLevelAtLeast(HistoryLevel.FULL)) {\n            ActivityInstanceEntity unfinishedActivityInstance = CommandContextUtil.getActivityInstanceEntityManager()\n                .findUnfinishedActivityInstance(sourceExecution);\n            if (unfinishedActivityInstance != null) {\n                activityInstanceId = unfinishedActivityInstance.getId();\n            }\n        }\n        return activityInstanceId;\n    }\n\n    protected void resolveProcessDefinitionInfo() {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();\n        if (processEngineConfiguration == null) {\n            // We are outside of a command context so do not try to resolve anything\n            return;\n        }\n        ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId, false, processEngineConfiguration);\n        if (processDefinition == null) {\n            throw new FlowableException(\"Cannot get process definition for id \" + processDefinitionId + \" for \" + this);\n        }\n\n        this.processDefinitionKey = processDefinition.getKey();\n        this.processDefinitionName = processDefinition.getName();\n        this.processDefinitionVersion = processDefinition.getVersion();\n        this.processDefinitionCategory = processDefinition.getCategory();\n        this.deploymentId = processDefinition.getDeploymentId();\n    }\n\n    // toString /////////////////////////////////////////////////////////////////\n\n    @Override\n    public String toString() {\n        StringBuilder strb;\n        if (isProcessInstanceType()) {\n            strb = new StringBuilder(\"ProcessInstance[\" + getId() + \"] - definition '\" + getProcessDefinitionId() + \"'\");\n        } else {\n            strb = new StringBuilder();","sourceCodeStart":1517,"sourceCodeEnd":1553,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/entity/ExecutionEntityImpl.java#L1517-L1553","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: deleting a deployment while instances run\nrepositoryService.deleteDeployment(deploymentId);\n\n// after: only delete when no instances remain\nlong count = runtimeService.createProcessInstanceQuery()\n    .processDefinitionId(procDefId).count();\nif (count == 0) {\n    repositoryService.deleteDeployment(deploymentId);\n}","handlingStrategy":"validation","validationCode":"ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionId(procDefId).singleResult();\nif (pd == null) {\n    throw new IllegalStateException(\"Unknown process definition: \" + procDefId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    entity.ensureProcessDefinitionInitialized();\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Cannot get process definition\")) {\n        // redeploy or re-map definition before continuing\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["flowable","process-definition","deployment","data-integrity"],"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-14T05:17:10.506Z"}