{"record":{"id":"fd2a054da764fdbc","repo":"flowable/flowable-engine","slug":"no-deployment-with-id-deploymentid-fd2a05","errorCode":null,"errorMessage":"no deployment with id ${deploymentId}","messagePattern":"no deployment with id (.+?)","errorType":"exception","errorClass":"org.activiti.engine.ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/rules/RulesHelper.java","lineNumber":42,"sourceCode":"/**\n * @author Tom Baeyens\n */\npublic class RulesHelper {\n\n    public static KieBase findKnowledgeBaseByDeploymentId(String deploymentId) {\n        DeploymentCache<Object> knowledgeBaseCache = Context\n                .getProcessEngineConfiguration()\n                .getDeploymentManager()\n                .getKnowledgeBaseCache();\n\n        KieBase knowledgeBase = (KieBase) knowledgeBaseCache.get(deploymentId);\n        if (knowledgeBase == null) {\n            DeploymentEntity deployment = Context\n                    .getCommandContext()\n                    .getDeploymentEntityManager()\n                    .findDeploymentById(deploymentId);\n            if (deployment == null) {\n                throw new ActivitiObjectNotFoundException(\"no deployment with id \" + deploymentId, Deployment.class);\n            }\n            Context\n                    .getProcessEngineConfiguration()\n                    .getDeploymentManager()\n                    .deploy(deployment);\n            knowledgeBase = (KieBase) knowledgeBaseCache.get(deploymentId);\n            if (knowledgeBase == null) {\n                throw new ActivitiException(\"deployment \" + deploymentId + \" doesn't contain any rules\");\n            }\n        }\n        return knowledgeBase;\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/rules/RulesHelper.java#L24-L56","documentation":"RulesHelper.findKnowledgeBaseByDeploymentId looks up the deployment by id via the DeploymentEntityManager; if no DeploymentEntity exists for that id it throws ActivitiObjectNotFoundException carrying the Deployment.class entity type. The rules (Drools) support cannot build a KieBase from a deployment that does not exist.","triggerScenarios":"Invoking a rule task (or otherwise triggering findKnowledgeBaseByDeploymentId) with a deploymentId that is not present in ACT_RE_DEPLOYMENT — e.g. a stale id after redeployment/cleanup or a hard-coded id from another database.","commonSituations":"Referencing a deployment id from an old environment, database cleaned of history while process definitions still reference the id, id copied between test and production databases, typo in the configured deployment id of a rule task.","solutions":["Query the repository (RepositoryService.createDeploymentQuery().deploymentId(deploymentId)) to confirm the id exists before running the rule task.","Fix the deploymentId reference in the BPMN rule task / configuration to point at an existing deployment.","Recreate the rules deployment if it was deleted, and update references to the new id.","Check you are connected to the environment (database) where the deployment was actually made."],"exampleFix":"// before\nKieBase kb = RulesHelper.findKnowledgeBaseByDeploymentId(\"deploy-123-stale\");\n// after\nDeployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) throw new IllegalStateException(\"deployment missing: \" + deploymentId);\nKieBase kb = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);","handlingStrategy":"try-catch","validationCode":"Deployment dep = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) throw new IllegalStateException(\"no deployment: \" + deploymentId);","typeGuard":null,"tryCatchPattern":"try {\n    return RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);\n} catch (ActivitiObjectNotFoundException e) {\n    logger.warn(\"rules deployment {} missing; redeploy rules\", deploymentId);\n    throw e;\n}","preventionTips":["Store deployment ids per environment, never hard-code across environments.","Resolve the id by deployment name/key at runtime instead of storing raw ids.","Check database connectivity points to the expected environment."],"tags":["rules","deployment","drools","entity-not-found"],"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-18T11:17:12.947Z"}