{"record":{"id":"199200be87f11e4e","repo":"hibernate/hibernate-orm","slug":"transactionmanager-reported-transaction-status-as","errorCode":null,"errorMessage":"TransactionManager reported transaction status as unknwon","messagePattern":"TransactionManager reported transaction status as unknwon","errorType":"exception","errorClass":"TransactionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaStatusHelper.java","lineNumber":65,"sourceCode":"\t\t\tthrow new TransactionException( \"Could not determine transaction status\", se );\n\t\t}\n\t}\n\n\t/**\n\t * Extract the status code from the current {@link jakarta.transaction.Transaction} associated with the\n\t * given {@link TransactionManager}\n\t *\n\t * @param transactionManager The {@link TransactionManager} from which to extract the status.\n\t *\n\t * @return The transaction status\n\t *\n\t * @throws TransactionException If the {@link TransactionManager} reports the status as unknown\n\t */\n\tpublic static int getStatus(TransactionManager transactionManager) {\n\t\ttry {\n\t\t\tfinal int status = transactionManager.getStatus();\n\t\t\tif ( status == STATUS_UNKNOWN ) {\n\t\t\t\tthrow new TransactionException( \"TransactionManager reported transaction status as unknwon\" );\n\t\t\t}\n\t\t\treturn status;\n\t\t}\n\t\tcatch ( SystemException se ) {\n\t\t\tthrow new TransactionException( \"Could not determine transaction status\", se );\n\t\t}\n\t}\n\n\t/**\n\t * Does the given status code indicate an active transaction?\n\t *\n\t * @param status The transaction status code to check\n\t *\n\t * @return True if the code indicates active; false otherwise.\n\t */\n\tpublic static boolean isActive(int status) {\n\t\treturn status == STATUS_ACTIVE;\n\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaStatusHelper.java#L47-L83","documentation":"The TransactionManager overload of JtaStatusHelper.getStatus(): identical logic to the UserTransaction variant, but the status comes from TransactionManager.getStatus(). A returned STATUS_UNKNOWN means the transaction's fate is indeterminate, so Hibernate throws TransactionException. Note the message contains a typo ('unknwon'), useful when grepping logs or Hibernate sources.","triggerScenarios":"Hibernate resolving current-transaction state via the TransactionManager (JTA platform lookups, transaction coordinator joins) while the manager reports STATUS_UNKNOWN — commonly during recovery after resource failure or an in-doubt transaction.","commonSituations":"Narayaya/Atomikos or WebLogic/WebSphere JTA recovering after a crash; XA resource (database, JMS broker) failure mid-transaction; transaction manager restart; in-doubt transactions requiring administrative resolution.","solutions":["Complete or let the TM finish recovery; resolve in-doubt transactions via the TM admin tooling if needed","Fix the failing XA resource so future transactions complete deterministically","Retry on a new transaction once TransactionManager.getStatus() returns a known code","Verify the jta.platform setting matches the actual transaction manager"],"exampleFix":"// before\n// Hibernate session/tx operation while TransactionManager reports STATUS_UNKNOWN\nem.persist(order); // -> TransactionException: 'TransactionManager reported transaction status as unknwon'\n\n// after\nint status = transactionManager.getStatus();\nif (status == Status.STATUS_UNKNOWN) {\n    awaitRecoveryThenRetry(); // or fail fast with actionable message\n}\nelse {\n    em.persist(order);\n}","handlingStrategy":"retry","validationCode":"int status = transactionManager.getStatus();\nif (status == javax.transaction.Status.STATUS_UNKNOWN) {\n    throw new IllegalStateException(\"JTA transaction status unknown; retry after recovery\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    // session/transaction work that inspects JTA status via TransactionManager\n} catch (org.hibernate.TransactionException e) {\n    if (String.valueOf(e.getMessage()).contains(\"unknwon\")) { // sic — Hibernate typo\n        scheduleRetry(); // wait for TM recovery, then use a new transaction\n    } else {\n        throw e;\n    }\n}","preventionTips":["Resolve in-doubt transactions with the TM's administrative tools rather than retrying into them","Keep XA resources healthy; STATUS_UNKNOWN typically follows a resource failure mid-transaction","Probe TransactionManager.getStatus() before starting units of work in recovery-prone environments"],"tags":["hibernate","jta","transaction-manager","status-unknown","recovery"],"backgroundTag":"jta-status-unknown","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}