{"record":{"id":"994ef3385443a108","repo":"hibernate/hibernate-orm","slug":"unable-to-apply-requested-transaction-timeout-994ef3","errorCode":null,"errorMessage":"Unable to apply requested transaction timeout","messagePattern":"Unable to apply requested transaction timeout","errorType":"exception","errorClass":"TransactionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaTransactionAdapterUserTransactionImpl.java","lineNumber":118,"sourceCode":"\n\t@Override\n\tpublic void markRollbackOnly(){\n\t\ttry {\n\t\t\tuserTransaction.setRollbackOnly();\n\t\t}\n\t\tcatch (SystemException e) {\n\t\t\tthrow new TransactionException( \"Unable to mark transaction for rollback only\", e );\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setTimeOut(int seconds) {\n\t\tif ( seconds > 0 ) {\n\t\t\ttry {\n\t\t\t\tuserTransaction.setTransactionTimeout( seconds );\n\t\t\t}\n\t\t\tcatch (SystemException e) {\n\t\t\t\tthrow new TransactionException( \"Unable to apply requested transaction timeout\", e );\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":100,"sourceCodeEnd":123,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaTransactionAdapterUserTransactionImpl.java#L100-L123","documentation":"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.","triggerScenarios":"Transaction.setTimeout(n) with n > 0, typically applied per-transaction before begin or via BMT timeout configuration, when userTransaction.setTransactionTimeout throws SystemException.","commonSituations":"Milliseconds passed where seconds are expected; exceeding the TM maximum timeout; setting the timeout after the transaction began; UT context restrictions.","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"],"exampleFix":"// before\nut.setTransactionTimeout(30_000); // ms-as-seconds, exceeds TM limits\n\n// after\nut.setTransactionTimeout(30); // seconds","handlingStrategy":"validation","validationCode":"// Clamp to a sane seconds range before applying\nint seconds = Math.min(Math.max(requestedSeconds, 1), tmMaxTimeoutSeconds);\nif ( seconds > 0 ) {\n    session.getTransaction().setTimeout(seconds);\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.getTransaction().setTimeout(seconds);\n}\ncatch (TransactionException e) {\n    log.warn(\"UT rejected timeout {}s; continuing with default\", seconds, e);\n}","preventionTips":["Pass seconds, not milliseconds","Clamp values to the TM maximum timeout","Set timeouts before the transaction begins"],"tags":["jta","transactions","hibernate","usertransaction","timeout"],"backgroundTag":"transaction-timeout-set-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}