{"record":{"id":"f01b6ac915d74d81","repo":"flowable/flowable-engine","slug":"deployment-for-process-definition-does-not-exist","errorCode":null,"errorMessage":"deployment for process definition does not exist: <deploymentId>","messagePattern":"deployment for process definition does not exist: <deploymentId>","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/deploy/DeploymentManager.java","lineNumber":127,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"Invalid process definition id : null\");\n        }\n\n        // first try the cache\n        BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);\n\n        if (bpmnModel == null) {\n            ProcessDefinition processDefinition = findDeployedProcessDefinitionById(processDefinitionId);\n            if (processDefinition == null) {\n                throw new ActivitiObjectNotFoundException(\"no deployed process definition found with id '\" + processDefinitionId + \"'\", ProcessDefinition.class);\n            }\n\n            // Fetch the resource\n            String resourceName = processDefinition.getResourceName();\n            ResourceEntity resource = Context.getCommandContext().getResourceEntityManager()\n                    .findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);\n            if (resource == null) {\n                if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {\n                    throw new ActivitiObjectNotFoundException(\"deployment for process definition does not exist: \"\n                            + processDefinition.getDeploymentId(), Deployment.class);\n                } else {\n                    throw new ActivitiObjectNotFoundException(\"no resource found with name '\" + resourceName\n                            + \"' in deployment '\" + processDefinition.getDeploymentId() + \"'\", InputStream.class);\n                }\n            }\n\n            // Convert the bpmn 2.0 xml to a bpmn model\n            BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();\n            bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);\n            bpmnModelCache.add(processDefinition.getId(), bpmnModel);\n        }\n        return bpmnModel;\n    }\n\n    public ProcessDefinition findDeployedLatestProcessDefinitionByKey(String processDefinitionKey) {\n        ProcessDefinition processDefinition = Context\n                .getCommandContext()","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/persistence/deploy/DeploymentManager.java#L109-L145","documentation":"ActivitiObjectNotFoundException thrown by DeploymentManager.getBpmnModelById when the process definition exists but its referenced deployment record is missing from the database. The engine fetches the definition's resource by deploymentId and resourceName; if the resource is null AND the deployment itself cannot be found, this error is thrown. It indicates database inconsistency: the process definition row survived but its parent deployment row did not.","triggerScenarios":"Calling getBpmnModelById(processDefinitionId) where ACT_RE_PROCDEF has a row whose deploymentId has no matching row in ACT_RE_DEPLOYMENT.","commonSituations":"Manual database cleanup that deleted ACT_RE_DEPLOYMENT rows but not ACT_RE_PROCDEF rows, partial rollback during deleteDeployment, or restoring a database backup incompletely.","solutions":["Repair the database: either restore the missing ACT_RE_DEPLOYMENT row or delete the orphaned ACT_RE_PROCDEF rows referencing the missing deployment","Redeploy the process definition to get a consistent deployment/definition pair","Check for foreign-key constraints being disabled or manual SQL cleanup scripts that broke referential integrity","Use RepositoryService.deleteDeployment(id, true) rather than manual deletes to remove deployments"],"exampleFix":"-- before (manual cleanup that breaks integrity)\nDELETE FROM ACT_RE_DEPLOYMENT WHERE ID_ = '100';\n-- after (delete the deployment through the engine)\nrepositoryService.deleteDeployment(\"100\", true); // cascades to definitions and instances","handlingStrategy":"validation","validationCode":"ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();\nDeployment d = pd == null ? null : repositoryService.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();\nif (d == null) throw new IllegalStateException(\"Orphaned process definition, deployment missing: \" + id);","typeGuard":null,"tryCatchPattern":"try {\n    return repositoryService.getBpmnModel(pdId);\n} catch (ActivitiObjectNotFoundException e) {\n    log.error(\"DB inconsistency for definition {}\", pdId, e);\n    return null;\n}","preventionTips":["Never delete deployment tables with manual SQL; use RepositoryService.deleteDeployment","Keep foreign key constraints enabled on ACT_* tables","Validate backups restore all ACT_RE_* and ACT_GE_* tables together"],"tags":["deployment","database-inconsistency","process-definition","persistence"],"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"}