{"record":{"id":"d6c70b35fdb338dd","repo":"quarkusio/quarkus","slug":"persistence-unit-s-is-contributed-by-an-extensi","errorCode":null,"errorMessage":"Persistence unit '%s' is contributed by an extension but is also configured by the application. A persistence unit contributed through the SPI must use a name that is not already configured through Quarkus configuration or a persistence.xml file.","messagePattern":"Persistence unit '(.+?)' is contributed by an extension but is also configured by the application\\. A persistence unit contributed through the SPI must use a name that is not already configured through Quarkus configuration or a persistence\\.xml file\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java","lineNumber":447,"sourceCode":"            Capabilities capabilities,\n            BuildProducer<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptors,\n            List<DefaultDataSourceDbVersionBuildItem> defaultDbVersions) {\n        // TODO move this validation to a dedicated method, preferably very early in the build?\n        //   See also a conceptually similar check in contributeQuarkusConfigToJpaModel\n        if (!additionalPersistenceUnits.isEmpty()) {\n            Set<String> userConfiguredPersistenceUnitNames = new HashSet<>(hibernateOrmConfig.namedPersistenceUnits().keySet());\n            for (PersistenceXmlDescriptorBuildItem persistenceXmlDescriptor : persistenceXmlDescriptors) {\n                userConfiguredPersistenceUnitNames.add(persistenceXmlDescriptor.getDescriptor().getName());\n            }\n            for (AdditionalPersistenceUnitBuildItem additionalPersistenceUnit : additionalPersistenceUnits) {\n                String persistenceUnitName = additionalPersistenceUnit.getPersistenceUnitName();\n                if (PersistenceUnitUtil.isDefaultPersistenceUnit(persistenceUnitName)) {\n                    throw new ConfigurationException(\n                            \"An extension attempted to contribute the default persistence unit through the SPI.\"\n                                    + \" Contributed persistence units must use a non-default name.\");\n                }\n                if (userConfiguredPersistenceUnitNames.contains(persistenceUnitName)) {\n                    throw new ConfigurationException(String.format(Locale.ROOT,\n                            \"Persistence unit '%s' is contributed by an extension but is also configured by the application.\"\n                                    + \" A persistence unit contributed through the SPI must use a name that is not already\"\n                                    + \" configured through Quarkus configuration or a persistence.xml file.\",\n                            persistenceUnitName));\n                }\n            }\n        }\n\n        // Produce the PUs having a persistence.xml: these are not reactive, as we don't allow using a persistence.xml for them.\n        for (PersistenceXmlDescriptorBuildItem persistenceXmlDescriptorBuildItem : persistenceXmlDescriptors) {\n            PersistenceUnitDescriptor xmlDescriptor = persistenceXmlDescriptorBuildItem.getDescriptor();\n            String puName = xmlDescriptor.getName();\n            Optional<JdbcDataSourceBuildItem> jdbcDataSource = findDefaultDataSource(jdbcDataSources);\n            var model = jpaModel.getModelPerPersistenceUnit().get(puName);\n            if (model == null) {\n                model = new JpaPersistenceUnitModel();\n            }\n            collectDialectConfigForPersistenceXml(puName, xmlDescriptor, defaultDbVersions);","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java#L429-L465","documentation":"When an extension contributes a persistence unit through the SPI, its name must be unique and must not collide with any persistence unit the application already defines through Quarkus configuration or a persistence.xml file. HibernateOrmProcessor throws a ConfigurationException when the contributed name is found among the user-configured persistence unit names.","triggerScenarios":"An AdditionalPersistenceUnitBuildItem produced by an extension has a persistenceUnitName that matches a name present in persistence.xml descriptors or in quarkus.hibernate-orm.\"<name>\".* configuration processed in buildBlockingPersistenceUnitFromPersistenceXml.","commonSituations":"Naming an extension-contributed PU the same as an application persistence.xml PU (e.g. both 'customers'); enabling an extension that contributes a PU while the app already defined that name in application.properties.","solutions":["Rename the extension-contributed persistence unit to a name not used in persistence.xml or quarkus.hibernate-orm config","Remove or rename the application-side persistence unit with the conflicting name"],"exampleFix":"// application.properties\n# before\nquarkus.hibernate-orm.\"audit\".datasource=audit-ds\n// after\nquarkus.hibernate-orm.\"audit-2\".datasource=audit-ds","handlingStrategy":"validation","validationCode":"Set<String> userPuNames = /* names from persistence.xml + quarkus.hibernate-orm.\"<name>\" keys */;\nif (userPuNames.contains(contributedPuName)) {\n    throw new IllegalArgumentException(\"PU name conflict: \" + contributedPuName);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a registry of persistence unit names used by the app and by extensions","Prefix extension-contributed PU names with the extension id to avoid collisions","Grep application.properties and persistence.xml for PU names before choosing one in an extension"],"tags":["hibernate-orm","persistence-unit","spi","name-conflict"],"backgroundTag":"persistence-unit-name-conflict","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}