{"record":{"id":"385767c731871717","repo":"flowable/flowable-engine","slug":"exception-while-autodeploying-cmmn-definitions-th-385767","errorCode":null,"errorMessage":"Exception while autodeploying CMMN definitions. This exception can be ignored if the root cause indicates a unique constraint violation, which is typically caused by two (or more) servers booting up at the exact same time and deploying the same definitions. ","messagePattern":"Exception while autodeploying CMMN definitions\\. This exception can be ignored if the root cause indicates a unique constraint violation, which is typically caused by two \\(or more\\) servers booting up at the exact same time and deploying the same definitions\\. ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/flowable-cmmn-spring/src/main/java/org/flowable/cmmn/spring/autodeployment/ResourceParentFolderAutoDeploymentStrategy.java","lineNumber":84,"sourceCode":"        // Create a deployment for each distinct parent folder using the name hint as a prefix\n        final Map<String, Set<Resource>> resourcesMap = createMap(resources);\n        for (final Entry<String, Set<Resource>> group : resourcesMap.entrySet()) {\n\n            final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());\n            final CmmnDeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName);\n\n            for (final Resource resource : group.getValue()) {\n                addResource(resource, deploymentBuilder);\n            }\n            try {\n\n                deploymentBuilder.deploy();\n\n            } catch (RuntimeException e) {\n                if (isThrowExceptionOnDeploymentFailure()) {\n                    throw e;\n                } else {\n                    LOGGER.warn(\"Exception while autodeploying CMMN definitions. \"\n                        + \"This exception can be ignored if the root cause indicates a unique constraint violation, \"\n                        + \"which is typically caused by two (or more) servers booting up at the exact same time and deploying the same definitions. \", e);\n                }\n            }\n        }\n\n    }\n\n    private Map<String, Set<Resource>> createMap(final Resource[] resources) {\n        final Map<String, Set<Resource>> resourcesMap = new HashMap<>();\n\n        for (final Resource resource : resources) {\n            final String parentFolderName = determineGroupName(resource);\n            if (resourcesMap.get(parentFolderName) == null) {\n                resourcesMap.put(parentFolderName, new HashSet<>());\n            }\n            resourcesMap.get(parentFolderName).add(resource);\n        }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-spring/src/main/java/org/flowable/cmmn/spring/autodeployment/ResourceParentFolderAutoDeploymentStrategy.java#L66-L102","documentation":"ResourceParentFolderAutoDeploymentStrategy deploys all CMMN resources under a common parent folder in one deployment; if deploymentBuilder.deploy() throws and throwExceptionOnDeploymentFailure is false, the RuntimeException is logged with this warning and swallowed. Same purpose as the other auto-deploy strategies: tolerate unique-constraint races during clustered startup.","triggerScenarios":"Spring auto-deployment where all resources share one parent folder (single deployment) and the deploy() call fails — unique constraint from two servers booting at once, duplicate deployment name, or invalid CMMN model.","commonSituations":"Clustered microservices sharing a Flowable DB starting simultaneously; repeated deployment of identical resources without deployResources deduplication; invalid .cmmn files bundled in a folder being auto-deployed.","solutions":["Inspect the logged root cause to distinguish benign unique-constraint races from real deployment errors.","Set throwExceptionOnDeploymentFailure=true on CmmnEngineConfiguration to rethrow instead of warn.","Use Flowable's deployment deduplication (same-deployment-name/lock) or ensure only one node performs auto-deployment.","Confirm case definitions exist after startup; if only the constraint fired, the definitions were deployed by the other instance.","Validate CMMN resources offline (e.g. with the CMMN XSD) if the cause is model validation."],"exampleFix":"// before\ncmmnEngineConfiguration.setThrowExceptionOnDeploymentFailure(false);\n// after\ncmmnEngineConfiguration.setThrowExceptionOnDeploymentFailure(true); // propagate deploy() RuntimeExceptions","handlingStrategy":"retry","validationCode":"// pre-flight: check whether the parent-folder deployment already exists\nboolean deployed = repositoryService.createDeploymentQuery()\n    .deploymentName(parentFolderDeploymentName).count() > 0;\nif (deployed) { /* skip redeployment */ }","typeGuard":null,"tryCatchPattern":"try {\n    applicationContext.publishEvent(new ApplicationReadyEvent(...)); // trigger deploy\n} catch (RuntimeException e) {\n    if (isUniqueConstraintViolation(e)) { LOGGER.info(\"Another node deployed first; ok\"); }\n    else throw e;\n}","preventionTips":["Enable throwExceptionOnDeploymentFailure for fail-fast behavior.","Deploy resources in a dedicated single-node phase of your rollout.","Keep parent-folder resources identical across nodes so constraint races stay benign.","Validate CMMN XML against the XSD in CI before bundling."],"tags":["auto-deployment","database","concurrency","cmmn"],"backgroundTag":"database-write-failed","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"}