{"record":{"id":"516b8e9c48ffd41c","repo":"flowable/flowable-engine","slug":"could-not-find-deployment-with-id-deploymentid-516b8e","errorCode":null,"errorMessage":"Could not find deployment with id <deploymentId>","messagePattern":"Could not find deployment with id <deploymentId>","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/cmd/SetDeploymentTenantIdCmd.java","lineNumber":52,"sourceCode":"    protected String deploymentId;\n    protected String newTenantId;\n\n    public SetDeploymentTenantIdCmd(String deploymentId, String newTenantId) {\n        this.deploymentId = deploymentId;\n        this.newTenantId = newTenantId;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (deploymentId == null) {\n            throw new FlowableIllegalArgumentException(\"deploymentId is null\");\n        }\n\n        // Update all entities\n\n        DmnDeploymentEntity deployment = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find deployment with id \" + deploymentId);\n        }\n\n        deployment.setTenantId(newTenantId);\n\n        // Doing process instances, executions and tasks with direct SQL updates\n        // (otherwise would not be performant)\n        CommandContextUtil.getDecisionEntityManager(commandContext).updateDecisionTenantIdForDeployment(deploymentId, newTenantId);\n\n        // Doing decision tables in memory, cause we need to clear the decision table cache\n        List<DmnDecision> decisionTables = new DecisionQueryImpl().deploymentId(deploymentId).list();\n        for (DmnDecision decisionTable : decisionTables) {\n            CommandContextUtil.getDmnEngineConfiguration().getDefinitionCache().remove(decisionTable.getId());\n        }\n\n        CommandContextUtil.getDeploymentEntityManager(commandContext).update(deployment);\n\n        return null;\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/cmd/SetDeploymentTenantIdCmd.java#L34-L70","documentation":"Same lookup guard as the parent-deployment command: SetDeploymentTenantIdCmd loads the deployment by id and throws FlowableObjectNotFoundException when findById returns null, before it updates the tenant and cascades direct SQL updates to dependent entities.","triggerScenarios":"Executing SetDeploymentTenantIdCmd with a deploymentId that does not exist in the DMN deployment table — wrong-engine id, deleted deployment, or mismatched database schema.","commonSituations":"Re-tenanting a deployment after it was deleted; copying ids from flowable logs of a different engine; multi-tenant setups where the deployment lives in another tenant's schema.","solutions":["Confirm existence with dmnRepositoryService.createDeploymentQuery().deploymentId(id).singleResult() first.","Verify the id is a DMN deployment id, not one from the process/case engine.","Ensure the engine configuration points at the database where the deployment was deployed.","Catch FlowableObjectNotFoundException and handle as a 404-style condition."],"exampleFix":"// before\ndmnManagementService.executeCommand(new SetDeploymentTenantIdCmd(deploymentId, newTenantId));\n// after\nDmnDeployment dep = dmnRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) {\n    throw new IllegalArgumentException(\"Unknown DMN deployment: \" + deploymentId);\n}\ndmnManagementService.executeCommand(new SetDeploymentTenantIdCmd(deploymentId, newTenantId));","handlingStrategy":"validation","validationCode":"DmnDeployment dep = dmnRepositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (dep == null) throw new IllegalArgumentException(\"Unknown DMN deployment: \" + deploymentId);","typeGuard":null,"tryCatchPattern":"try {\n    dmnManagementService.executeCommand(new SetDeploymentTenantIdCmd(deploymentId, tenantId));\n} catch (FlowableObjectNotFoundException e) {\n    // treat as 404\n}","preventionTips":["Verify deployment existence before tenant changes","Ensure engine datasource matches where the deployment lives","Never reuse ids across engines"],"tags":["flowable","dmn","deployment","not-found","tenant"],"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"}