{"record":{"id":"5e42d606040c9bd3","repo":"hibernate/hibernate-orm","slug":"unable-to-apply-requested-transaction-timeout","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/JtaTransactionAdapterTransactionManagerImpl.java","lineNumber":117,"sourceCode":"\n\t@Override\n\tpublic void markRollbackOnly() {\n\t\ttry {\n\t\t\ttransactionManager.setRollbackOnly();\n\t\t}\n\t\tcatch (SystemException e) {\n\t\t\tthrow new TransactionException( \"Could not set transaction to 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\ttransactionManager.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":99,"sourceCodeEnd":122,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/JtaTransactionAdapterTransactionManagerImpl.java#L99-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"Passing milliseconds where seconds are expected (producing huge values); TM maximum-timeout limits; calling setTimeout after the transaction has begun.","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"],"exampleFix":"// before: milliseconds passed where seconds are expected\nsession.getTransaction().setTimeout(30_000); // 30000 s, exceeds TM limits -> SystemException\n\n// after\nsession.getTransaction().setTimeout(30); // seconds","handlingStrategy":"validation","validationCode":"// Clamp the timeout 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(\"TM rejected timeout {}s; continuing with default\", seconds, e);\n}","preventionTips":["Always pass seconds, never milliseconds","Know your TM's maximum timeout (e.g., Narayana maximumDefaultTimeout) and clamp values","Apply timeouts before the transaction begins"],"tags":["jta","transactions","hibernate","timeout"],"backgroundTag":"transaction-timeout-set-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}