hibernate/hibernate-orm · error · TransactionException

Could not determine transaction status

Error message

Could not determine transaction status

What it means

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'.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/engine/transaction/internal/jta/JtaStatusHelper.java:47

	/**
	 * Extract the status code from a {@link UserTransaction}
	 *
	 * @param userTransaction The {@link UserTransaction} from which to extract the status.
	 *
	 * @return The transaction status
	 *
	 * @throws TransactionException If the {@link UserTransaction} reports the status as unknown
	 */
	public static int getStatus(UserTransaction userTransaction) {
		try {
			final int status = userTransaction.getStatus();
			if ( status == STATUS_UNKNOWN ) {
				throw new TransactionException( "UserTransaction reported transaction status as unknown" );
			}
			return status;
		}
		catch ( SystemException se ) {
			throw new TransactionException( "Could not determine transaction status", se );
		}
	}

	/**
	 * Extract the status code from the current {@link jakarta.transaction.Transaction} associated with the
	 * given {@link TransactionManager}
	 *
	 * @param transactionManager The {@link TransactionManager} from which to extract the status.
	 *
	 * @return The transaction status
	 *
	 * @throws TransactionException If the {@link TransactionManager} reports the status as unknown
	 */
	public static int getStatus(TransactionManager transactionManager) {
		try {
			final int status = transactionManager.getStatus();
			if ( status == STATUS_UNKNOWN ) {
				throw new TransactionException( "TransactionManager reported transaction status as unknwon" );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Read the caused-by SystemException and transaction manager logs to find the real infrastructure failure
  2. Ensure the JTA transaction manager is started and hibernate.transaction.jta.platform points to the correct resolver for your runtime
  3. Avoid session/transaction usage during startup/shutdown before the TM is available
  4. Retry once the manager is healthy; treat this as an environment error, not a data error

Example fix

// before
// session used while UserTransaction.getStatus() throws SystemException
Session s = sf.openSession(); // -> TransactionException: Could not determine transaction status

// after
try {
    int status = userTransaction.getStatus();
    // safe to interact with Hibernate/JTA now
} catch (SystemException e) {
    // surface the infrastructure failure instead of letting Hibernate wrap it
    throw new IllegalStateException("Transaction manager unavailable", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    userTransaction.getStatus(); // probe TM before session work
} catch (javax.transaction.SystemException e) {
    throw new IllegalStateException("Transaction manager unavailable; fix JTA setup", e);
}

Try / catch

try {
    // session/transaction work
} catch (org.hibernate.TransactionException e) {
    if ("Could not determine transaction status".equals(e.getMessage()) && e.getCause() instanceof javax.transaction.SystemException se) {
        // infrastructure failure — surface TM health, do not retry blindly
        throw new IllegalStateException("JTA transaction manager failure", se);
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/1e651df1fabacf80. Report an issue: GitHub.