quarkusio/quarkus · error · RuntimeException

Error getting the current transaction

Error message

Error getting the current transaction

What it means

Thrown by TransactionContext.getCurrentTransaction() when transactionManager.get().getTransaction() throws a SystemException. The transactional context needs the current Transaction object to associate contextual bean instances, and if Narayana cannot answer that lookup the failure is wrapped in this RuntimeException. It indicates the transaction service itself is malfunctioning rather than merely 'no transaction active'.

Source

Thrown at extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java:191

        try {
            int currentStatus = transaction.getStatus();
            return currentStatus == Status.STATUS_ACTIVE ||
                    currentStatus == Status.STATUS_MARKED_ROLLBACK ||
                    currentStatus == Status.STATUS_PREPARED ||
                    currentStatus == Status.STATUS_UNKNOWN ||
                    currentStatus == Status.STATUS_PREPARING ||
                    currentStatus == Status.STATUS_COMMITTING ||
                    currentStatus == Status.STATUS_ROLLING_BACK;
        } catch (SystemException e) {
            throw new RuntimeException("Error getting the status of the current transaction", e);
        }
    }

    private Transaction getCurrentTransaction() {
        try {
            return transactionManager.get().getTransaction();
        } catch (SystemException e) {
            throw new RuntimeException("Error getting the current transaction", e);
        }
    }

    /**
     * Representing of the context state. It's a container for all available beans in the context.
     * It's filled during bean usage and cleared on destroy.
     */
    private static class TransactionContextState implements ContextState, Synchronization {

        private final Lock lock = new ReentrantLock();

        private final ConcurrentMap<Contextual<?>, ContextInstanceHandle<?>> mapBeanToInstanceHandle = new ConcurrentHashMap<>();

        TransactionContextState(Transaction transaction) {
            try {
                transaction.registerSynchronization(this);
            } catch (RollbackException | SystemException e) {
                throw new RuntimeException("Cannot register synchronization", e);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the wrapped cause (getCause()) to identify the underlying SystemException
  2. Fix transaction manager configuration under quarkus.transaction.* (object store path, node name uniqueness)
  3. Avoid accessing @TransactionScoped beans from shutdown hooks or async threads after context termination
  4. Update Quarkus/Narayana versions if the failure is a known reaper race (fixed in later versions)
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    jakarta.transaction.Transaction tx = transactionManager.getTransaction();
} catch (SystemException e) { /* TM unhealthy — abort operation */ }

Try / catch

try { doTransactionalWork(); } catch (RuntimeException e) {
    if (e.getCause() instanceof SystemException) { log.error("Current-tx lookup failed", e); }
    throw e;
}

Prevention

When it happens

Trigger: Invoking TransactionContext.get(), getState(), transaction(), or getCurrentTransaction() while the TransactionManager's getTransaction() call fails with SystemException — e.g. during TM shutdown, corrupted thread-local transaction state, or a broken TransactionManager instance.

Common situations: Beans with @TransactionScoped accessed while the app is shutting down; Narayana reaper/shutdown racing with in-flight requests; classloading issues producing a broken TransactionManager supplier; invalid arjuna configuration.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/01faafd31eb740ce. Report an issue: GitHub.