{"record":{"id":"efea6c9d574d4bc0","repo":"flowable/flowable-engine","slug":"could-not-find-a-deployment-with-id-deploymen","errorCode":null,"errorMessage":"Could not find a deployment with id '\" + deploymentId + \"'.","messagePattern":"Could not find a deployment with id '\" \\+ deploymentId \\+ \"'\\.","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/deploy/DeploymentManager.java","lineNumber":184,"sourceCode":"        }\n\n        return appResourceObject;\n    }\n\n    public AppModel getAppResourceModel(String deploymentId) {\n        Object appResourceObject = getAppResourceObject(deploymentId);\n        if (!(appResourceObject instanceof AppModel)) {\n            throw new FlowableException(\"App resource is not of type AppModel\");\n        }\n\n        return (AppModel) appResourceObject;\n    }\n\n    public void removeDeployment(String deploymentId, boolean cascade) {\n\n        DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId);\n        if (deployment == null) {\n            throw new FlowableObjectNotFoundException(\"Could not find a deployment with id '\" + deploymentId + \"'.\", DeploymentEntity.class);\n        }\n\n        if (Flowable5Util.isFlowable5Deployment(deployment, processEngineConfiguration)) {\n            processEngineConfiguration.getFlowable5CompatibilityHandler().deleteDeployment(deploymentId, cascade);\n            return;\n        }\n\n        for (EngineDeployer deployer : deployers) {\n            deployer.undeploy(deployment, cascade);\n        }\n\n        // Remove any process definition from the cache\n        List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list();\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();\n        FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();\n\n        for (ProcessDefinition processDefinition : processDefinitions) {\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/persistence/deploy/DeploymentManager.java#L166-L202","documentation":"Flowable throws FlowableObjectNotFoundException when deleting a deployment whose id does not exist in ACT_RE_DEPLOYMENT. repositoryService.deleteDeployment(deploymentId) (cascade or not) requires an existing deployment row; a null lookup result triggers this error before any removal or Flowable 5 delegation happens.","triggerScenarios":"repositoryService.deleteDeployment(\"dep-1\") where dep-1 was already deleted, never existed, or belongs to a different database/schema; re-running cleanup scripts that delete twice.","commonSituations":"Repeated teardown in tests deleting the same deployment; ids copied from another environment; deployments cleaned by another process while a job still references them.","solutions":["Verify existence first: repositoryService.createDeploymentQuery().deploymentId(id).singleResult()","Make deletion idempotent in cleanup code by skipping when the query returns null","Check you are connected to the right database where the deployment lives"],"exampleFix":"// before\nrepositoryService.deleteDeployment(deploymentId, true);\n// after\nif (repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() != null) {\n    repositoryService.deleteDeployment(deploymentId, true);\n}","handlingStrategy":"validation","validationCode":"if (repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult() != null) {\n    repositoryService.deleteDeployment(deploymentId, true);\n}","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.deleteDeployment(deploymentId, true);\n} catch (FlowableObjectNotFoundException e) {\n    // already deleted — treat as idempotent success\n}","preventionTips":["Make cleanup scripts idempotent","Guard deletes with an existence query","Use one shared environment/database reference for id bookkeeping"],"tags":["flowable","deployment","not-found","delete"],"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-14T11:17:12.474Z"}