{"record":{"id":"cac4484e6ed0a6db","repo":"flowable/flowable-engine","slug":"no-deployment-found-for-id-deploymentid","errorCode":null,"errorMessage":"No deployment found for id = '${deploymentId}'","messagePattern":"No deployment found for id = '(.+?)'","errorType":"validation","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/SetDeploymentCategoryCmd.java","lineNumber":52,"sourceCode":"    protected String category;\r\n\r\n    public SetDeploymentCategoryCmd(String deploymentId, String category) {\r\n        this.deploymentId = deploymentId;\r\n        this.category = category;\r\n    }\r\n\r\n    @Override\r\n    public Void execute(CommandContext commandContext) {\r\n\r\n        if (deploymentId == null) {\r\n            throw new FlowableIllegalArgumentException(\"Deployment id is null\");\r\n        }\r\n\r\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\r\n        DeploymentEntity deployment = processEngineConfiguration.getDeploymentEntityManager().findById(deploymentId);\r\n\r\n        if (deployment == null) {\r\n            throw new FlowableObjectNotFoundException(\"No deployment found for id = '\" + deploymentId + \"'\", Deployment.class);\r\n        }\r\n\r\n        if (Flowable5Util.isFlowable5Deployment(deployment, commandContext)) {\r\n            processEngineConfiguration.getFlowable5CompatibilityHandler().setDeploymentCategory(deploymentId, category);\r\n        }\r\n\r\n        // Update category\r\n        deployment.setCategory(category);\r\n\r\n        FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();\r\n        if (eventDispatcher != null && eventDispatcher.isEnabled()) {\r\n            eventDispatcher.dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, deployment),\r\n                    processEngineConfiguration.getEngineCfgKey());\r\n        }\r\n\r\n        return null;\r\n    }\r\n\r","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/SetDeploymentCategoryCmd.java#L34-L70","documentation":"SetDeploymentCategoryCmd.execute throws FlowableObjectNotFoundException when no deployment exists with the given deploymentId. The message includes the id and the entity type is Deployment.class. This is a missing-resource guard after findById returned null.","triggerScenarios":"Calling repositoryService.setDeploymentCategory(deploymentId, category) with an id of a deployment that was deleted, never created, or from a different database/schema.","commonSituations":"Stale ids cached after a redeploy or cleanup job; wrong database (test vs prod) so the deployment isn't there; case-sensitivity/typo in the id; cascade delete removed the deployment.","solutions":["Verify the deployment id exists via repositoryService.createDeploymentQuery().deploymentId(id).singleResult() before setting the category.","Confirm the engine points at the correct database where the deployment is stored.","Catch FlowableObjectNotFoundException and treat it as a data-consistency problem (stale id) rather than retrying blindly."],"exampleFix":"// before\nrepositoryService.setDeploymentCategory(oldId, \"prod\"); // oldId stale\n// after\nif (repositoryService.createDeploymentQuery().deploymentId(id).count() > 0) {\n    repositoryService.setDeploymentCategory(id, \"prod\");\n}","handlingStrategy":"try-catch","validationCode":"boolean exists = repositoryService.createDeploymentQuery().deploymentId(deploymentId).count() > 0;\nif (!exists) {\n    throw new IllegalStateException(\"Deployment \" + deploymentId + \" no longer exists\");\n}\nrepositoryService.setDeploymentCategory(deploymentId, category);","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.setDeploymentCategory(deploymentId, category);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Deployment {} not found; possibly stale reference\", deploymentId);\n    // refresh deployment references or skip\n}","preventionTips":["Re-query the deployment id after redeploys or cleanup jobs before referencing it.","Verify the engine's database configuration matches the environment the deployment lives in.","Handle FlowableObjectNotFoundException as a stale-data signal, not a transient failure."],"tags":["flowable","deployment","not-found","resource"],"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"}