{"record":{"id":"69048b7e8dae3576","repo":"flowable/flowable-engine","slug":"no-deployment-with-id-deploymentid","errorCode":null,"errorMessage":"no deployment with id ${deploymentId}","messagePattern":"no deployment with id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/app/RulesHelper.java","lineNumber":36,"sourceCode":"import org.flowable.common.engine.impl.persistence.deploy.DeploymentCache;\nimport org.flowable.engine.impl.persistence.entity.DeploymentEntity;\nimport org.flowable.engine.impl.util.CommandContextUtil;\nimport org.flowable.engine.repository.Deployment;\nimport org.kie.api.KieBase;\n\n/**\n * @author Tom Baeyens\n */\npublic class RulesHelper {\n\n    public static KieBase findKnowledgeBaseByDeploymentId(String deploymentId) {\n        DeploymentCache<Object> knowledgeBaseCache = CommandContextUtil.getProcessEngineConfiguration().getDeploymentManager().getKnowledgeBaseCache();\n\n        KieBase knowledgeBase = (KieBase) knowledgeBaseCache.get(deploymentId);\n        if (knowledgeBase == null) {\n            DeploymentEntity deployment = CommandContextUtil.getDeploymentEntityManager().findById(deploymentId);\n            if (deployment == null) {\n                throw new FlowableObjectNotFoundException(\"no deployment with id \" + deploymentId, Deployment.class);\n            }\n            CommandContextUtil.getProcessEngineConfiguration().getDeploymentManager().deploy(deployment);\n            knowledgeBase = (KieBase) knowledgeBaseCache.get(deploymentId);\n            if (knowledgeBase == null) {\n                throw new FlowableException(\"deployment \" + deploymentId + \" doesn't contain any rules\");\n            }\n        }\n        return knowledgeBase;\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":47,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/app/RulesHelper.java#L18-L47","documentation":"RulesHelper.findKnowledgeBaseByDeploymentId looks up a KieBase in the deployment's knowledge base cache; when absent it loads the deployment from the persistence store, and if no deployment entity exists for the given id it throws FlowableObjectNotFoundException with the Deployment class. The supplied deploymentId simply does not exist in the repository.","triggerScenarios":"Invoking rules (RulesDeployer / rules task) with a deploymentId string that was never deployed or was deleted: findKnowledgeBaseByDeploymentId(\"bogus-id\").","commonSituations":"Hardcoded deployment ids copied from another environment (test vs prod databases); the deployment was removed via deleteDeployment while rule artifacts still reference it; typo in the deployment id.","solutions":["Verify the deploymentId exists: repositoryService.createDeploymentQuery().deploymentId(id).count() > 0, and use an existing id.","Look up the deployment containing the rules via repositoryService.createDeploymentQuery().latest().list() or by resource name to get the correct id.","If the deployment was deleted, redeploy the rules (.drl) resources to create a new deployment and use the new id."],"exampleFix":"// before\nKieBase kb = rulesHelper.findKnowledgeBaseByDeploymentId(\"1234-does-not-exist\");\n// after\nDeployment dep = repositoryService.createDeploymentQuery()\n    .deploymentName(\"rulesDeployment\").latestVersion().singleResult();\nKieBase kb = rulesHelper.findKnowledgeBaseByDeploymentId(dep.getId());","handlingStrategy":"validation","validationCode":"long count = repositoryService.createDeploymentQuery()\n    .deploymentId(deploymentId).count();\nif (count == 0) {\n    throw new IllegalArgumentException(\"Deployment does not exist: \" + deploymentId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    KieBase kb = rulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);\n} catch (FlowableObjectNotFoundException e) {\n    // e.getObjectClass() == Deployment.class: re-resolve a valid deployment id\n}","preventionTips":["Always resolve deployment ids dynamically via DeploymentQuery, never hardcode across environments","Check deployment existence before using it for rules","Beware deleteDeployment invalidating stored references to rule deployments"],"tags":["rules","drools","deployment-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"}