{"record":{"id":"db823b00b0348729","repo":"quarkusio/quarkus","slug":"a-legacy-persistence-xml-file-is-present-in-the-cl","errorCode":null,"errorMessage":"A legacy persistence.xml file is present in the classpath, but Hibernate ORM is also configured through the Quarkus config file.\nLegacy persistence.xml files and Quarkus configuration cannot be used at the same time.\nTo ignore persistence.xml files, set the configuration property 'quarkus.hibernate-orm.persistence-xml.ignore' to 'true'.\nTo use persistence.xml files, remove all 'quarkus.hibernate-orm*' properties from the Quarkus config file.","messagePattern":"A legacy persistence\\.xml file is present in the classpath, but Hibernate ORM is also configured through the Quarkus config file\\.\nLegacy persistence\\.xml files and Quarkus configuration cannot be used at the same time\\.\nTo ignore persistence\\.xml files, set the configuration property 'quarkus\\.hibernate-orm\\.persistence-xml\\.ignore' to 'true'\\.\nTo use persistence\\.xml files, remove all 'quarkus\\.hibernate-orm\\*' properties from the Quarkus config 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":553,"sourceCode":"        // so that those classes are indexed, bytecode-enhanced, registered for reflection and assigned to their\n        // persistence unit without the contributing extension having to produce a separate AdditionalJpaModelBuildItem.\n        for (AdditionalPersistenceUnitBuildItem additionalPersistenceUnit : additionalPersistenceUnits) {\n            Set<String> persistenceUnits = Set.of(additionalPersistenceUnit.getPersistenceUnitName());\n            for (String className : additionalPersistenceUnit.getManagedClassNames()) {\n                additionalJpaModel.produce(new AdditionalJpaModelBuildItem(className, persistenceUnits));\n            }\n        }\n    }\n\n    @BuildStep\n    public void contributeQuarkusConfigToJpaModel(\n            BuildProducer<JpaModelPersistenceUnitContributionBuildItem> jpaModelPuContributions,\n            HibernateOrmConfig hibernateOrmConfig, List<PersistenceXmlDescriptorBuildItem> persistenceXmlDescriptors) {\n        // TODO move this validation to a dedicated method, preferably very early in the build?\n        //   See also a conceptually similar check in buildBlockingPersistenceUnitFromPersistenceXml\n        if (!persistenceXmlDescriptors.isEmpty()) {\n            if (hibernateOrmConfig.isAnyNonPersistenceXmlPropertySet()) {\n                throw new ConfigurationException(\n                        \"A legacy persistence.xml file is present in the classpath, but Hibernate ORM is also configured through the Quarkus config file.\\n\"\n                                + \"Legacy persistence.xml files and Quarkus configuration cannot be used at the same time.\\n\"\n                                + \"To ignore persistence.xml files, set the configuration property\"\n                                + \" 'quarkus.hibernate-orm.persistence-xml.ignore' to 'true'.\\n\"\n                                + \"To use persistence.xml files, remove all '\" + HIBERNATE_ORM_CONFIG_PREFIX\n                                + \"*' properties from the Quarkus config file.\");\n            } else {\n                // It's theoretically possible to use the Quarkus Hibernate ORM extension\n                // without setting any build-time configuration property,\n                // so the condition above might not catch all attempts to use persistence.xml and Quarkus-configured PUs\n                // at the same time.\n                // At that point, the only thing we can do is log something,\n                // so that hopefully people in that situation will notice that their Quarkus configuration is being ignored.\n                LOG.infof(\n                        \"A legacy persistence.xml file is present in the classpath. This file will be used to configure JPA/Hibernate ORM persistence units,\"\n                                + \" and any configuration of the Hibernate ORM extension will be ignored.\"\n                                + \" To ignore persistence.xml files instead, set the configuration property\"\n                                + \" 'quarkus.hibernate-orm.persistence-xml.ignore' to 'true'.\");","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java#L535-L571","documentation":"Quarkus supports configuring Hibernate ORM either through a legacy META-INF/persistence.xml or through quarkus.hibernate-orm.* configuration properties, but never both at once. If a persistence.xml is on the classpath and any non-persistence-xml quarkus.hibernate-orm property is set, contributeQuarkusConfigToJpaModel throws a ConfigurationException explaining the two remediation paths.","triggerScenarios":"A META-INF/persistence.xml descriptor is present AND hibernateOrmConfig.isAnyNonPersistenceXmlPropertySet() is true (any quarkus.hibernate-orm* property other than quarkus.hibernate-orm.persistence-xml.ignore is set in application config).","commonSituations":"Migrating a classic Java EE app that keeps persistence.xml while also adding quarkus.hibernate-orm.datasource or dialect settings; leaving a leftover persistence.xml in test resources while the app uses Quarkus config.","solutions":["Set quarkus.hibernate-orm.persistence-xml.ignore=true to ignore the persistence.xml and keep Quarkus config","Delete META-INF/persistence.xml and configure everything via quarkus.hibernate-orm.* properties","Remove all quarkus.hibernate-orm* properties to use only the persistence.xml"],"exampleFix":"// application.properties\n// before\nquarkus.hibernate-orm.datasource.name=myds\n// after (choose one)\nquarkus.hibernate-orm.persistence-xml.ignore=true\nquarkus.hibernate-orm.datasource.name=myds\n# ...and delete META-INF/persistence.xml","handlingStrategy":"validation","validationCode":"boolean hasPersistenceXml = getClass().getResource(\"/META-INF/persistence.xml\") != null;\nboolean hasQuarkusOrmProps = configContainsPrefix(\"quarkus.hibernate-orm.\");\nif (hasPersistenceXml && hasQuarkusOrmProps\n    && !configContains(\"quarkus.hibernate-orm.persistence-xml.ignore=true\")) {\n    throw new IllegalStateException(\"Choose either persistence.xml or quarkus.hibernate-orm.* config\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search the classpath (including test resources) for META-INF/persistence.xml when migrating to Quarkus config","Set quarkus.hibernate-orm.persistence-xml.ignore=true intentionally if persistence.xml must stay","Never mix quarkus.hibernate-orm.* properties with an active persistence.xml"],"tags":["hibernate-orm","persistence-xml","configuration-conflict"],"backgroundTag":"persistence-xml-config-conflict","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}