{"record":{"id":"2260917e5bf8bc53","repo":"hibernate/hibernate-orm","slug":"unknown-persistence-unit-transaction-type","errorCode":null,"errorMessage":"Unknown persistence unit transaction type : {}","messagePattern":"Unknown persistence unit transaction type : (.+?)","errorType":"exception","errorClass":"PersistenceException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceXmlParser.java","lineNumber":309,"sourceCode":"\t\telse if ( persistenceUnitDescriptor.getNonJtaDataSource() != null ) {\n\t\t\treturn RESOURCE_LOCAL;\n\t\t}\n\t\telse {\n\t\t\treturn defaultTransactionType;\n\t\t}\n\t}\n\n\tprivate static PersistenceUnitTransactionType parseTransactionType(String value) {\n\t\tif ( isEmpty( value ) ) {\n\t\t\treturn null;\n\t\t}\n\t\telse {\n\t\t\tfor ( var transactionType : PersistenceUnitTransactionType.values() ) {\n\t\t\t\tif ( transactionType.name().equalsIgnoreCase( value ) ) {\n\t\t\t\t\treturn transactionType;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new PersistenceException( \"Unknown persistence unit transaction type : \" + value );\n\t\t}\n\t}\n\n\tprivate JaxbPersistenceImpl loadUrlWithJaxb(URL xmlUrl) {\n\t\tfinal String resourceName = xmlUrl.toExternalForm();\n\t\ttry {\n\t\t\tvar connection = xmlUrl.openConnection();\n\t\t\t// avoid JAR locking on Windows and Tomcat\n\t\t\tconnection.setUseCaches( false );\n\t\t\ttry ( var inputStream = connection.getInputStream() ) {\n\t\t\t\treturn new ConfigurationBinder( classLoaderService )\n\t\t\t\t\t\t.bind( new StreamSource( inputStream ),\n\t\t\t\t\t\t\t\tnew Origin( SourceType.URL, resourceName ) )\n\t\t\t\t\t\t.getRoot();\n\t\t\t}\n\t\t\tcatch (IOException e) {\n\t\t\t\tthrow new PersistenceException( \"Unable to obtain input stream from [\" + resourceName + \"]\", e );\n\t\t\t}","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceXmlParser.java#L291-L327","documentation":"Thrown by PersistenceXmlParser.parseTransactionType() as a PersistenceException when the transaction-type attribute of a <persistence-unit> in persistence.xml is non-empty but matches neither RESOURCE_LOCAL nor JTA (case-insensitive). The parser enumerates PersistenceUnitTransactionType.values() and falls through to this error for any other value.","triggerScenarios":"Writing <persistence-unit name=\"x\" transaction-type=\"LOCAL\">, transaction-type=\"resource-local \" (trailing space), \"JTADataSource\", or any typo/unsupported value in META-INF/persistence.xml; the error surfaces when Hibernate parses the XML at bootstrap.","commonSituations":"Typos in hand-edited persistence.xml; copy-paste from tutorials using non-standard values; believing values like \"RESOURCE\" or \"NON_JTA\" are accepted; XML editors not validating against the persistence XSD.","solutions":["Set transaction-type to exactly RESOURCE_LOCAL or JTA (case-insensitive, no extra whitespace).","Use RESOURCE_LOCAL when your app manages transactions via EntityTransaction (or Spring's resource-local setup); use JTA only with a real transaction manager (WildFly, Narayana, Atomikos).","Validate persistence.xml against the Jakarta Persistence XSD to catch attribute typos early.","If you actually wanted JTA, also provide the JTA data source and transaction coordinator config."],"exampleFix":"<!-- before -->\n<persistence-unit name=\"demo\" transaction-type=\"LOCAL\">\n\n<!-- after -->\n<persistence-unit name=\"demo\" transaction-type=\"RESOURCE_LOCAL\">","handlingStrategy":"validation","validationCode":"// fail fast with your own message before the parser does\nString tx = puElement.getAttribute(\"transaction-type\");\nif (!tx.isBlank() && !tx.equalsIgnoreCase(\"JTA\") && !tx.equalsIgnoreCase(\"RESOURCE_LOCAL\")) {\n    throw new IllegalArgumentException(\"Invalid transaction-type '\" + tx + \"' in persistence.xml\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate persistence.xml against the Jakarta Persistence XSD in your build (XML editor or unit test).","Copy the two legal values from the spec, never from memory of tutorials."],"tags":["hibernate","jpa","persistence-xml","configuration","transaction-type"],"backgroundTag":"invalid-configuration-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}