{"record":{"id":"01faafd31eb740ce","repo":"quarkusio/quarkus","slug":"error-getting-the-current-transaction","errorCode":null,"errorMessage":"Error getting the current transaction","messagePattern":"Error getting the current transaction","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java","lineNumber":191,"sourceCode":"        try {\n            int currentStatus = transaction.getStatus();\n            return currentStatus == Status.STATUS_ACTIVE ||\n                    currentStatus == Status.STATUS_MARKED_ROLLBACK ||\n                    currentStatus == Status.STATUS_PREPARED ||\n                    currentStatus == Status.STATUS_UNKNOWN ||\n                    currentStatus == Status.STATUS_PREPARING ||\n                    currentStatus == Status.STATUS_COMMITTING ||\n                    currentStatus == Status.STATUS_ROLLING_BACK;\n        } catch (SystemException e) {\n            throw new RuntimeException(\"Error getting the status of the current transaction\", e);\n        }\n    }\n\n    private Transaction getCurrentTransaction() {\n        try {\n            return transactionManager.get().getTransaction();\n        } catch (SystemException e) {\n            throw new RuntimeException(\"Error getting the current transaction\", e);\n        }\n    }\n\n    /**\n     * Representing of the context state. It's a container for all available beans in the context.\n     * It's filled during bean usage and cleared on destroy.\n     */\n    private static class TransactionContextState implements ContextState, Synchronization {\n\n        private final Lock lock = new ReentrantLock();\n\n        private final ConcurrentMap<Contextual<?>, ContextInstanceHandle<?>> mapBeanToInstanceHandle = new ConcurrentHashMap<>();\n\n        TransactionContextState(Transaction transaction) {\n            try {\n                transaction.registerSynchronization(this);\n            } catch (RollbackException | SystemException e) {\n                throw new RuntimeException(\"Cannot register synchronization\", e);","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/context/TransactionContext.java#L173-L209","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped cause (getCause()) to identify the underlying SystemException","Fix transaction manager configuration under quarkus.transaction.* (object store path, node name uniqueness)","Avoid accessing @TransactionScoped beans from shutdown hooks or async threads after context termination","Update Quarkus/Narayana versions if the failure is a known reaper race (fixed in later versions)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try {\n    jakarta.transaction.Transaction tx = transactionManager.getTransaction();\n} catch (SystemException e) { /* TM unhealthy — abort operation */ }","typeGuard":null,"tryCatchPattern":"try { doTransactionalWork(); } catch (RuntimeException e) {\n    if (e.getCause() instanceof SystemException) { log.error(\"Current-tx lookup failed\", e); }\n    throw e;\n}","preventionTips":["Do not access @TransactionScoped beans after application shutdown starts","Ensure unique and valid quarkus.transaction.* configuration","Investigate the root SystemException cause rather than retrying blindly","Keep Quarkus/Narayana patched for known TM races"],"tags":["jta","transaction","narayana","quarkus"],"backgroundTag":"transaction-manager-system-exception","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}