{"record":{"id":"ce66c7b999c99e64","repo":"quarkusio/quarkus","slug":"the-transaction-is-not-active","errorCode":null,"errorMessage":"The transaction is not active!","messagePattern":"The transaction is not active!","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionScopedNotifier.java","lineNumber":50,"sourceCode":"            beforeDestroyed = Arc.container().beanManager().getEvent()\n                    .select(TransactionId.class, BeforeDestroyed.Literal.of(TransactionScoped.class));\n        }\n        beforeDestroyed.fire(transactionId);\n    }\n\n    void destroyed(TransactionId transactionId) {\n        if (destroyed == null) {\n            destroyed = Arc.container().beanManager().getEvent()\n                    .select(TransactionId.class, Destroyed.Literal.of(TransactionScoped.class));\n        }\n        destroyed.fire(transactionId);\n    }\n\n    TransactionId getTransactionId() throws SystemException {\n        try {\n            return new TransactionId(TransactionImple.getTransaction().toString());\n        } catch (Exception e) {\n            throw new SystemException(\"The transaction is not active!\");\n        }\n    }\n\n    // we use this wrapper because if we fire an event with string payload then any \"@Observes String payload\" would be notified\n    public static final class TransactionId {\n\n        private final String value;\n\n        public TransactionId(String value) {\n            this.value = value;\n        }\n\n        @Override\n        public String toString() {\n            return value;\n        }\n\n        @Override","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionScopedNotifier.java#L32-L68","documentation":"TransactionScopedNotifier.getTransactionId() builds the TransactionId event payload from the current JTA transaction; if TransactionImple.getTransaction() fails (no active transaction on the thread), every exception is converted into jakarta.transaction.SystemException(\"The transaction is not active!\"). It is thrown while firing transaction-scoped observer events, meaning the code ran outside a real transaction.","triggerScenarios":"An observer or callback tied to the transaction scope (e.g. @Observes of transaction events via TransactionScopedNotifier) executing when no JTA transaction is active on the current thread — e.g. after commit/rollback completed or code running on a non-transactional thread.","commonSituations":"@Transactional missing on the entry point so transaction-scoped beans/events run without a transaction; observer logic invoked after the transaction already finished; async threads detached from the transactional context.","solutions":["Annotate the calling method (or a wrapping method) with @Transactional so a transaction is active","Wrap getTransactionId-dependent logic in a check for active transaction status before firing/observing","Catch SystemException and treat it as 'no transaction' if the observer must tolerate transaction-less execution"],"exampleFix":"// before\npublic void doWork() { notifier.getTransactionId(); }\n// after\n@Transactional\npublic void doWork() { notifier.getTransactionId(); }","handlingStrategy":"try-catch","validationCode":"if (!TransactionManager.transactionManager().getStatus().equals(Status.STATUS_ACTIVE)) { /* skip or start a transaction first */ }","typeGuard":"boolean hasActiveTransaction() { try { return javax.transaction.Status.STATUS_ACTIVE == com.arjuna.ats.jta.TransactionManager.transactionManager().getStatus(); } catch (Exception e) { return false; } }","tryCatchPattern":"try { TransactionId id = getTransactionId(); ... } catch (SystemException e) { log.warn(\"no active transaction, skipping id\"); }","preventionTips":["Annotate entry points that use transaction-scoped features with @Transactional","Do not fire/observe transaction events from background threads without transaction propagation","Check Status.STATUS_ACTIVE before transaction-dependent logic"],"tags":["narayana-jta","transactions","system-exception","cdi","transaction-scope"],"backgroundTag":"no-active-transaction","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"}