{"record":{"id":"1616eb5423d1320b","repo":"flowable/flowable-engine","slug":"could-not-find-deployment-with-id","errorCode":null,"errorMessage":"Could not find deployment with id ","messagePattern":"Could not find deployment with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java","lineNumber":90,"sourceCode":"    }\n\n    public ChangeDeploymentTenantIdCmd(String deploymentId, String newTenantId, DeploymentMergeStrategy deploymentMergeStrategy) {\n        this.deploymentId = deploymentId;\n        this.newTenantId = newTenantId;\n        this.deploymentMergeStrategy = deploymentMergeStrategy;\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        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        DeploymentEntity deployment = processEngineConfiguration.getDeploymentEntityManager().findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find deployment with id \" + deploymentId, Deployment.class);\n        }\n\n        if (Flowable5Util.isFlowable5Deployment(deployment, commandContext)) {\n            processEngineConfiguration.getFlowable5CompatibilityHandler().changeDeploymentTenantId(deploymentId, newTenantId);\n            return null;\n        }\n\n        deploymentMergeStrategy.prepareMerge(commandContext, deploymentId, newTenantId);\n        String oldTenantId = deployment.getTenantId();\n        deployment.setTenantId(newTenantId);\n\n        // Doing process instances, executions and tasks with direct SQL updates\n        // (otherwise would not be performant)\n        processEngineConfiguration.getProcessDefinitionEntityManager().updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);\n        processEngineConfiguration.getExecutionEntityManager().updateExecutionTenantIdForDeployment(deploymentId, newTenantId);\n        processEngineConfiguration.getTaskServiceConfiguration().getTaskService().updateTaskTenantIdForDeployment(deploymentId, newTenantId);\n        JobService jobService = processEngineConfiguration.getJobServiceConfiguration().getJobService();\n        jobService.updateAllJobTypesTenantIdForDeployment(deploymentId, newTenantId);","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java#L72-L108","documentation":"After validating the id, ChangeDeploymentTenantIdCmd looks up the deployment by id. If no deployment exists with that id, Flowable throws FlowableObjectNotFoundException (with Deployment.class as the missing type).","triggerScenarios":"Calling repositoryService.changeDeploymentTenantId(id, tenantId) with an id of a deleted, never-deployed, or typo'd deployment; using an id from a different engine/database.","commonSituations":"Stale cached deployment ids after redeployment or DB cleanup; hard-coded ids in tests; pointing at the wrong database schema or tenant-scoped data.","solutions":["Verify the deployment id exists via repositoryService.createDeploymentQuery().deploymentId(id).singleResult().","Correct the id source (config, process variable, lookup by key instead of id).","Check that the engine is connected to the database/schema that holds the deployment."],"exampleFix":"// before\nrepositoryService.changeDeploymentTenantId(deploymentId, tenantId);\n// after\nDeployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d != null) {\n    repositoryService.changeDeploymentTenantId(deploymentId, tenantId);\n}","handlingStrategy":"validation","validationCode":"Deployment d = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();\nif (d == null) {\n    throw new IllegalArgumentException(\"Deployment does not exist: \" + deploymentId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.changeDeploymentTenantId(deploymentId, tenantId);\n} catch (FlowableObjectNotFoundException e) {\n    // deployment missing; log and surface to user\n}","preventionTips":["Resolve deployments by key/query rather than hard-coded ids.","Refresh ids after redeployments or database cleanup."],"tags":["flowable","deployment","not-found","tenant"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}