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 UserTransaction.setTransactionTimeout(seconds); a SystemException is wrapped as 'Unable to apply requested transaction timeout'. The UT/TM refused or failed the request - commonly a value outside the TM's allowed range, a call made too late (after begin), or a TM error. 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/JtaTransactionAdapterUserTransactionImpl.java:118
@Override
public void markRollbackOnly(){
try {
userTransaction.setRollbackOnly();
}
catch (SystemException e) {
throw new TransactionException( "Unable to mark transaction for rollback only", e );
}
}
@Override
public void setTimeOut(int seconds) {
if ( seconds > 0 ) {
try {
userTransaction.setTransactionTimeout( seconds );
}
catch (SystemException e) {
throw new TransactionException( "Unable to apply requested transaction timeout", e );
}
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Pass seconds within the TM's allowed range
- Raise the TM maximum timeout if the value is legitimate
- Set the timeout before the transaction begins
- Check TM logs for the underlying SystemException
Example fix
// before ut.setTransactionTimeout(30_000); // ms-as-seconds, exceeds TM limits // after ut.setTransactionTimeout(30); // seconds
Defensive patterns
Strategy: validation
Validate before calling
// Clamp 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("UT rejected timeout {}s; continuing with default", seconds, e);
} Prevention
- Pass seconds, not milliseconds
- Clamp values to the TM maximum timeout
- Set timeouts before the transaction begins
When it happens
Trigger: Transaction.setTimeout(n) with n > 0, typically applied per-transaction before begin or via BMT timeout configuration, when userTransaction.setTransactionTimeout throws SystemException.
Common situations: Milliseconds passed where seconds are expected; exceeding the TM maximum timeout; setting the timeout after the transaction began; UT context restrictions.
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
- JTA UserTransaction.begin() failed
- JTA UserTransaction.commit() failed
- JTA UserTransaction.rollback() failed
- UserTransaction reported transaction status as unknown
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/994ef3385443a108.
Report an issue: GitHub.