hibernate/hibernate-orm · error · TransactionException

TransactionManager reported transaction status as unknwon

Error message

TransactionManager reported transaction status as unknwon

What it means

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.

Source

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

			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" );
			}
			return status;
		}
		catch ( SystemException se ) {
			throw new TransactionException( "Could not determine transaction status", se );
		}
	}

	/**
	 * Does the given status code indicate an active transaction?
	 *
	 * @param status The transaction status code to check
	 *
	 * @return True if the code indicates active; false otherwise.
	 */
	public static boolean isActive(int status) {
		return status == STATUS_ACTIVE;
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Complete or let the TM finish recovery; resolve in-doubt transactions via the TM admin tooling if needed
  2. Fix the failing XA resource so future transactions complete deterministically
  3. Retry on a new transaction once TransactionManager.getStatus() returns a known code
  4. Verify the jta.platform setting matches the actual transaction manager

Example fix

// before
// Hibernate session/tx operation while TransactionManager reports STATUS_UNKNOWN
em.persist(order); // -> TransactionException: 'TransactionManager reported transaction status as unknwon'

// after
int status = transactionManager.getStatus();
if (status == Status.STATUS_UNKNOWN) {
    awaitRecoveryThenRetry(); // or fail fast with actionable message
}
else {
    em.persist(order);
}
Defensive patterns

Strategy: retry

Validate before calling

int status = transactionManager.getStatus();
if (status == javax.transaction.Status.STATUS_UNKNOWN) {
    throw new IllegalStateException("JTA transaction status unknown; retry after recovery");
}

Try / catch

try {
    // session/transaction work that inspects JTA status via TransactionManager
} catch (org.hibernate.TransactionException e) {
    if (String.valueOf(e.getMessage()).contains("unknwon")) { // sic — Hibernate typo
        scheduleRetry(); // wait for TM recovery, then use a new transaction
    } else {
        throw e;
    }
}

Prevention

When it happens

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

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

Related errors


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