{"record":{"id":"36f9fead60eaa5dd","repo":"flowable/flowable-engine","slug":"no-deployment-with-id","errorCode":null,"errorMessage":"no deployment with id ","messagePattern":"no deployment with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/rules/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/rules/RulesHelper.java#L18-L47","documentation":"RulesHelper.findKnowledgeBaseByDeploymentId looks up a KieBase (drools knowledge base) from the deployment cache for a given deployment id. If it is not cached, it loads the deployment; when no deployment with that id exists in ACT_RE_DEPLOYMENT it throws FlowableObjectNotFoundException. It is Flowable's rules/drools integration telling you the deployment id does not reference a persisted deployment.","triggerScenarios":"Passing a deployment id to the rules helper that was never deployed, already deleted, belongs to a different engine/database, or contains a typo; calling with a process definition id instead of a deployment id.","commonSituations":"Hardcoded deployment ids after re-deploying to another environment; cleanup jobs deleting old deployments while rules still reference them; multi-tenant setups querying the wrong tenant's data; copying ids from a different database.","solutions":["Verify the deployment id exists via repositoryService.createDeploymentQuery().deploymentId(id).singleResult().","Use the id returned by deployment.deploy() rather than a hardcoded value.","Check you are connected to the same database/tenant where the deployment was made.","If the deployment was deleted, redeploy the rules archive and use the new id."],"exampleFix":"// before\nKieBase kb = RulesHelper.findKnowledgeBaseByDeploymentId(\"deployment-123\"); // may not exist\n// after\nDeployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d == null) {\n    throw new IllegalStateException(\"Unknown deployment id: \" + deploymentId);\n}\nKieBase kb = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);","handlingStrategy":"validation","validationCode":"Deployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d == null) throw new IllegalArgumentException(\"Unknown deployment id: \" + deploymentId);","typeGuard":null,"tryCatchPattern":"try {\n    return RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);\n} catch (FlowableObjectNotFoundException e) {\n    log.error(\"No deployment {} in this database/tenant\", deploymentId);\n    throw e;\n}","preventionTips":["Always use the id returned by DeploymentBuilder.deploy().","Never hardcode deployment ids across environments.","Check you operate against the same database/schema and tenant as the deployment.","Query deployment existence before rules lookups in cleanup-sensitive systems."],"tags":["java","flowable","rules","drools","deployment","not-found"],"backgroundTag":"record-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"}