{"record":{"id":"1e651df1fabacf80","repo":"hibernate/hibernate-orm","slug":"could-not-determine-transaction-status","errorCode":null,"errorMessage":"Could not determine transaction status","messagePattern":"Could not determine transaction status","errorType":"exception","errorClass":"TransactionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaStatusHelper.java","lineNumber":47,"sourceCode":"\t/**\n\t * Extract the status code from a {@link UserTransaction}\n\t *\n\t * @param userTransaction The {@link UserTransaction} from which to extract the status.\n\t *\n\t * @return The transaction status\n\t *\n\t * @throws TransactionException If the {@link UserTransaction} reports the status as unknown\n\t */\n\tpublic static int getStatus(UserTransaction userTransaction) {\n\t\ttry {\n\t\t\tfinal int status = userTransaction.getStatus();\n\t\t\tif ( status == STATUS_UNKNOWN ) {\n\t\t\t\tthrow new TransactionException( \"UserTransaction reported transaction status as unknown\" );\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 * 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\" );","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaStatusHelper.java#L29-L65","documentation":"The catch arm of JtaStatusHelper.getStatus(UserTransaction): when UserTransaction.getStatus() itself throws javax.transaction.SystemException, the transaction manager failed to answer at all. Hibernate wraps it as TransactionException('Could not determine transaction status') with the original SystemException as cause, distinguishing 'manager answered unknown' from 'manager failed'.","triggerScenarios":"Hibernate asking the UserTransaction for its status while the JTA implementation throws SystemException — manager not started, shutting down, misconfigured JNDI binding for UserTransaction, or internal TM error during recovery.","commonSituations":"Wrong or missing hibernate.transaction.jta.platform configuration; application code touching sessions before/after the transaction manager lifecycle (e.g. in a ServletContextListener at startup); the UserTransaction bound in JNDI belonging to a different TM than the one Hibernate uses; TM crash.","solutions":["Read the caused-by SystemException and transaction manager logs to find the real infrastructure failure","Ensure the JTA transaction manager is started and hibernate.transaction.jta.platform points to the correct resolver for your runtime","Avoid session/transaction usage during startup/shutdown before the TM is available","Retry once the manager is healthy; treat this as an environment error, not a data error"],"exampleFix":"// before\n// session used while UserTransaction.getStatus() throws SystemException\nSession s = sf.openSession(); // -> TransactionException: Could not determine transaction status\n\n// after\ntry {\n    int status = userTransaction.getStatus();\n    // safe to interact with Hibernate/JTA now\n} catch (SystemException e) {\n    // surface the infrastructure failure instead of letting Hibernate wrap it\n    throw new IllegalStateException(\"Transaction manager unavailable\", e);\n}","handlingStrategy":"try-catch","validationCode":"try {\n    userTransaction.getStatus(); // probe TM before session work\n} catch (javax.transaction.SystemException e) {\n    throw new IllegalStateException(\"Transaction manager unavailable; fix JTA setup\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    // session/transaction work\n} catch (org.hibernate.TransactionException e) {\n    if (\"Could not determine transaction status\".equals(e.getMessage()) && e.getCause() instanceof javax.transaction.SystemException se) {\n        // infrastructure failure — surface TM health, do not retry blindly\n        throw new IllegalStateException(\"JTA transaction manager failure\", se);\n    }\n    throw e;\n}","preventionTips":["Configure the correct jta.platform resolver and remove competing transaction managers from the classpath","Do not open sessions before the TM is started (startup/shutdown listeners)","Alert on SystemException from getStatus() — it indicates TM-level failure, not a data problem"],"tags":["hibernate","jta","user-transaction","system-exception","transaction-manager"],"backgroundTag":"jta-status-lookup-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}