{"record":{"id":"1d1457b0af70b225","repo":"hibernate/hibernate-orm","slug":"problem-locating-validating-jta-transaction","errorCode":null,"errorMessage":"Problem locating/validating JTA transaction","messagePattern":"Problem locating/validating JTA transaction","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java","lineNumber":116,"sourceCode":"\tprivate static @Nonnull Transaction getTransaction(TransactionManager transactionManager) {\n\t\ttry {\n\t\t\tfinal var transaction = transactionManager.getTransaction();\n\t\t\tif ( transaction == null ) {\n\t\t\t\tthrow new HibernateException( \"Unable to locate current JTA transaction\" );\n\t\t\t}\n\t\t\tif ( !isActive( transaction.getStatus() ) ) {\n\t\t\t\t// We could register the session against the transaction even though it is\n\t\t\t\t// not started, but we'd have no guarantee of ever getting the map\n\t\t\t\t// entries cleaned up (aside from spawning threads).\n\t\t\t\tthrow new HibernateException( \"Current transaction is not in progress\" );\n\t\t\t}\n\t\t\treturn transaction;\n\t\t}\n\t\tcatch ( HibernateException e ) {\n\t\t\tthrow e;\n\t\t}\n\t\tcatch ( Throwable t ) {\n\t\t\tthrow new HibernateException( \"Problem locating/validating JTA transaction\", t );\n\t\t}\n\t}\n\n\t/**\n\t * Builds a {@link CleanupSync} capable of cleaning up the current session map as an after transaction\n\t * callback.\n\t *\n\t * @param transactionIdentifier The transaction identifier under which the current session is registered.\n\t * @return The cleanup synch.\n\t */\n\tprivate CleanupSync buildCleanupSynch(Object transactionIdentifier) {\n\t\treturn new CleanupSync( transactionIdentifier, this );\n\t}\n\n\t/**\n\t * Strictly provided for subclassing purposes; specifically to allow long-session\n\t * support.  This implementation always just opens a new session.\n\t *","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/context/internal/JTASessionContext.java#L98-L134","documentation":"Catch-all wrapper thrown when TransactionManager.getTransaction() or Transaction.getStatus() raised an unexpected system exception rather than returning normally. The real failure (JNDI problem, transaction manager not started, recovery store error) is attached as the cause; the HibernateException message itself is generic on purpose.","triggerScenarios":"Broken transaction-manager wiring: configured JtaPlatform class present but its TM/JNDI backend unavailable, Narayana/Atomikos not started or its object store locked, or a TM that throws on getTransaction()/getStatus() in an unexpected state.","commonSituations":"Clustered TM misconfiguration; concurrent boot leaving the recovery store locked (stale .tx locks); partial JTA dependencies after a dependency cleanup; version mismatch between the JTA provider and Hibernate's platform adapter.","solutions":["Read the cause chain — it carries the actual TM/JNDI/store error and names the resource to fix","Verify the transaction manager starts standalone (Narayana/Atomikos bootstrap smoke test) before wiring Hibernate","Clear stale transaction recovery locks/object store leftovers only after confirming no live TM owns them","Align JTA provider and hibernate.transaction.jta.platform versions, and prefer autodetection inside EE containers"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return sessionFactory.getCurrentSession();\n} catch (org.hibernate.HibernateException e) {\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause();\n    log.error(\"JTA infrastructure failure accessing current session: {}\", root, root); // root names the real TM/JNDI/store error\n    throw e;\n}","preventionTips":["Always inspect the cause chain before acting on this wrapper","Smoke-test transaction-manager startup independently of Hibernate","Keep JTA provider, its object store, and hibernate.transaction.jta.platform versions aligned"],"tags":["hibernate","jta","transaction-manager","infrastructure","root-cause-chaining"],"backgroundTag":"transaction-manager-lookup-failure","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}