quarkusio/quarkus · error · JtaPlatformException
Could not access JTA Transaction to register synchronization
Error message
Could not access JTA Transaction to register synchronization
What it means
QuarkusJtaPlatform.registerSynchronization() obtains the current JTA transaction from the TransactionManager and registers a Hibernate Synchronization on it. If any exception occurs while accessing the transaction (no transaction manager, transaction lookup failure, unexpected status), it wraps the cause in org.hibernate.resource.transaction.spi.JtaPlatformException with this message.
Source
Thrown at extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusJtaPlatform.java:75
UserTransaction userTransaction = this.userTransaction;
if (userTransaction == null) {
userTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction();
this.userTransaction = userTransaction;
}
return userTransaction;
}
@Override
public Object getTransactionIdentifier(final Transaction transaction) {
return transaction;
}
@Override
public void registerSynchronization(Synchronization synchronization) {
try {
getTransactionManager().getTransaction().registerSynchronization(synchronization);
} catch (Exception e) {
throw new JtaPlatformException("Could not access JTA Transaction to register synchronization", e);
}
}
@Override
public boolean canRegisterSynchronization() {
// no need to check STATUS_MARKED_ROLLBACK since synchronizations can't be registered in that state
return retrieveTransactionSynchronizationRegistry().getTransactionStatus() == STATUS_ACTIVE;
}
@Override
public int getCurrentStatus() throws SystemException {
return this.retrieveTransactionManager().getStatus();
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Ensure the quarkus-narayana-jta extension is present and the code runs within Quarkus-managed (CDI/request) context so the TransactionManager is available.
- Verify a transaction is actually active when the session is used — annotate with @Transactional or use QuarkusTransaction explicitly.
- Inspect the wrapped cause of the JtaPlatformException for the underlying lookup error (e.g. NamingException or NullPointerException).
- Avoid sharing EntityManagerFactory/session instances across environments where Quarkus's JTA platform wasn't initialized.
Example fix
// before: session used outside transaction scope
em.find(Entity.class, id); // registration fails
// after
@Transactional
void load() { em.find(Entity.class, id); } Defensive patterns
Strategy: try-catch
Validate before calling
// Check JTA availability and active transaction before ORM work
jakarta.transaction.TransactionManager tm = getTransactionManager();
if (tm == null || tm.getTransaction() == null) {
throw new IllegalStateException("No active JTA transaction; annotate with @Transactional");
} Try / catch
try {
return em.find(Entity.class, id);
} catch (org.hibernate.resource.transaction.spi.JtaPlatformException e) {
if (e.getMessage() != null && e.getMessage().contains("Could not access JTA Transaction")) {
throw new IllegalStateException(
"Run ORM work inside a Quarkus-managed @Transactional context", e);
}
throw e;
} Prevention
- Always run session/EntityManager work inside @Transactional or QuarkusTransaction scopes
- Keep quarkus-narayana-jta on the classpath of applications using Hibernate ORM
- Read the wrapped cause of JtaPlatformException to identify lookup failures early
- Avoid manual TransactionManager lookups; use Quarkus's transaction APIs
When it happens
Trigger: Hibernate ORM calling registerSynchronization (e.g. to flush before queries or register before-completion callbacks) when getTransactionManager().getTransaction() throws — such as when the JTA transaction manager is unavailable or the transaction subsystem is misconfigured.
Common situations: Running Hibernate ORM outside a Quarkus-managed context where the transaction manager isn't set; broken Narayana/transaction extension configuration; using a session in a context without proper transaction integration; classloading or ArC initialization problems preventing the TransactionManager lookup.
Related errors
- Not supported for JTA entity managers
- Cannot use the StatelessSession because neither a transactio
- Cannot use the StatelessSession because no transaction is ac
- Error getting the status of the current transaction
- Error getting the current transaction
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/faafeec393eb020c.
Report an issue: GitHub.