{"record":{"id":"c315b9bcdd8449a9","repo":"hibernate/hibernate-orm","slug":"could-not-obtain-narayana-transactionmanager-insta","errorCode":null,"errorMessage":"Could not obtain Narayana TransactionManager instance","messagePattern":"Could not obtain Narayana TransactionManager instance","errorType":"exception","errorClass":"JtaPlatformException","httpStatus":null,"severity":"critical","filePath":"hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NarayanaJtaPlatform.java","lineNumber":32,"sourceCode":" *\n * @author Emmanuel Bernard\n * @author Steve Ebersole\n */\npublic class NarayanaJtaPlatform extends AbstractJtaPlatform {\n\n\tpublic static final String TM_CLASS_NAME = \"com.arjuna.ats.jta.TransactionManager\";\n\tpublic static final String UT_CLASS_NAME = \"com.arjuna.ats.jta.UserTransaction\";\n\n\t@Override\n\tprotected TransactionManager locateTransactionManager() {\n\t\ttry {\n\t\t\treturn (TransactionManager) serviceRegistry().requireService( ClassLoaderService.class )\n\t\t\t\t\t.classForName( TM_CLASS_NAME )\n\t\t\t\t\t.getMethod( \"transactionManager\" )\n\t\t\t\t\t.invoke( null );\n\t\t}\n\t\tcatch ( Exception e ) {\n\t\t\tthrow new JtaPlatformException( \"Could not obtain Narayana TransactionManager instance\", e );\n\t\t}\n\t}\n\n\t@Override\n\tprotected UserTransaction locateUserTransaction() {\n\t\ttry {\n\t\t\treturn (UserTransaction) serviceRegistry()\n\t\t\t\t\t.requireService( ClassLoaderService.class )\n\t\t\t\t\t.classForName( UT_CLASS_NAME )\n\t\t\t\t\t.getMethod( \"userTransaction\" )\n\t\t\t\t\t.invoke( null );\n\t\t}\n\t\tcatch ( Exception e ) {\n\t\t\tthrow new JtaPlatformException( \"Could not obtain Narayana UserTransaction instance\", e );\n\t\t}\n\t}\n}\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/NarayanaJtaPlatform.java#L14-L50","documentation":"NarayanaJtaPlatform.locateTransactionManager() reflectively calls the static transactionManager() on com.arjuna.ats.jta.TransactionManager. JtaPlatformException('Could not obtain Narayana TransactionManager instance') means the Arjuna JTA classes are not on Hibernate's classpath, or the Narayana transaction service is not initialized in this JVM, so the static accessor cannot return a manager.","triggerScenarios":"hibernate.transaction.jta.platform=NarayanaJtaPlatform without org.jboss.narayana.jta:narayana-jta; Arjuna classes present but the transaction/recovery manager not started before Hibernate first needs it; a Narayana version where the class exists but transactionManager() throws during initialization.","commonSituations":"Spring Boot with a misconfigured Narayana starter; integration tests booting Hibernate before the transaction manager service; Narayana 5.x to 7.x upgrades changing initialization requirements.","solutions":["Add org.jboss.narayana.jta:narayana-jta with its transitive dependencies","Ensure Narayana is bootstrapped (narayana-spring-boot-starter or explicit initialization) before Hibernate sessions are used","Align hibernate-core and Narayana to a tested version combination","Verify Class.forName(\"com.arjuna.ats.jta.TransactionManager\") in the exact runtime classloader"],"exampleFix":"// before (pom.xml): only arjuna-core present, JTA facade missing\n// after (pom.xml):\n<dependency>\n    <groupId>org.jboss.narayana.jta</groupId>\n    <artifactId>narayana-jta</artifactId>\n    <version>7.0.2.Final</version>\n</dependency>","handlingStrategy":"validation","validationCode":"Class.forName(\"com.arjuna.ats.jta.TransactionManager\");\n// and the static call Hibernate performs:\nClass.forName(\"com.arjuna.ats.jta.TransactionManager\").getMethod(\"transactionManager\").invoke(null);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add org.jboss.narayana.jta:narayana-jta before enabling NarayanaJtaPlatform","Bootstrap Narayana before Hibernate sessions are used","Align hibernate-core and Narayana versions to a tested pair","Run a startup classpath check in the deployment environment, not only in tests"],"tags":["jta","narayana","arjuna","classpath","transaction-manager"],"backgroundTag":"jta-platform-misconfiguration","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}