hibernate/hibernate-orm · error · TransactionException
Unable to apply requested transaction timeout
Error message
Unable to apply requested transaction timeout
What it means
setTimeOut forwards positive values to TransactionManager.setTransactionTimeout(seconds); a SystemException from the TM is wrapped as 'Unable to apply requested transaction timeout'. The TM refused or failed the timeout request (commonly a value outside the TM's accepted range, or a TM error) - it does not mean a timeout fired. Values <= 0 are silently ignored because of the seconds > 0 guard.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaTransactionAdapterTransactionManagerImpl.java:117
@Override
public void markRollbackOnly() {
try {
transactionManager.setRollbackOnly();
}
catch (SystemException e) {
throw new TransactionException( "Could not set transaction to rollback only", e );
}
}
@Override
public void setTimeOut(int seconds) {
if ( seconds > 0 ) {
try {
transactionManager.setTransactionTimeout( seconds );
}
catch (SystemException e) {
throw new TransactionException( "Unable to apply requested transaction timeout", e );
}
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Pass a value within the TM's allowed range, expressed in seconds
- Raise the TM's maximum timeout (e.g., Narayana maximumDefaultTimeout) if the value is legitimate
- Apply the timeout before the transaction begins; some TMs reject changes on an active transaction
- Check TM logs for the underlying SystemException
Example fix
// before: milliseconds passed where seconds are expected session.getTransaction().setTimeout(30_000); // 30000 s, exceeds TM limits -> SystemException // after session.getTransaction().setTimeout(30); // seconds
Defensive patterns
Strategy: validation
Validate before calling
// Clamp the timeout to a sane seconds range before applying
int seconds = Math.min(Math.max(requestedSeconds, 1), tmMaxTimeoutSeconds);
if ( seconds > 0 ) {
session.getTransaction().setTimeout(seconds);
} Try / catch
try {
session.getTransaction().setTimeout(seconds);
}
catch (TransactionException e) {
log.warn("TM rejected timeout {}s; continuing with default", seconds, e);
} Prevention
- Always pass seconds, never milliseconds
- Know your TM's maximum timeout (e.g., Narayana maximumDefaultTimeout) and clamp values
- Apply timeouts before the transaction begins
When it happens
Trigger: session.getTransaction().setTimeout(n) with n > 0, or configuration-driven transaction timeout application, when setTransactionTimeout throws SystemException - e.g., n exceeds the TM's maximum (Narayana maximumDefaultTimeout) or the TM is in error.
Common situations: Passing milliseconds where seconds are expected (producing huge values); TM maximum-timeout limits; calling setTimeout after the transaction has begun.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Unable to apply requested transaction timeout
- Transaction is not accessible when using JTA with JPA-compli
- Exception pulsing TransactionCoordinator
- Explicitly joining a JTA transaction requires a JTA transact
- Unable to resume suspended transaction
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5e42d606040c9bd3.
Report an issue: GitHub.