{"record":{"id":"1ad4fa9c3f37fda2","repo":"hibernate/hibernate-orm","slug":"unable-to-suspend-current-jta-transaction-in-prepa","errorCode":null,"errorMessage":"Unable to suspend current JTA transaction in preparation for DDL execution","messagePattern":"Unable to suspend current JTA transaction in preparation for DDL execution","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/DdlTransactionIsolatorJtaImpl.java","lineNumber":51,"sourceCode":"\t}\n\n\tpublic DdlTransactionIsolatorJtaImpl(JdbcContext jdbcContext) {\n\t\tthis.jdbcContext = jdbcContext;\n\n\t\ttry {\n\t\t\tfinal var jtaPlatform = getJtaPlatform( jdbcContext );\n\t\t\tfinal var transactionManager = jtaPlatform.retrieveTransactionManager();\n\t\t\tif ( transactionManager == null ) {\n\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\"DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; \" +\n\t\t\t\t\t\t\"base JtaPlatform impl (\" + jtaPlatform + \")?\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tsuspendedTransaction = transactionManager.suspend();\n\t\t\tJTA_LOGGER.suspendedTransactionForDdlIsolation( suspendedTransaction );\n\t\t}\n\t\tcatch (SystemException e) {\n\t\t\tthrow new HibernateException( \"Unable to suspend current JTA transaction in preparation for DDL execution\" );\n\t\t}\n\n\t}\n\n\t@Override\n\tpublic JdbcContext getJdbcContext() {\n\t\treturn jdbcContext;\n\t}\n\n\t@Override\n\tpublic Connection getIsolatedConnection() {\n\t\treturn getIsolatedConnection(true);\n\t}\n\n\t@Override\n\tpublic Connection getIsolatedConnection(boolean autocommit) {\n\t\tif ( jdbcConnection == null ) {\n\t\t\ttry {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jta/internal/DdlTransactionIsolatorJtaImpl.java#L33-L69","documentation":"HibernateException from DdlTransactionIsolatorJtaImpl's constructor: a TransactionManager was found, but transactionManager.suspend() threw javax.transaction.SystemException while isolating DDL execution. Unlike the null-TM case, this is the JTA runtime itself failing the suspend operation (its error code is in the SystemException, which is unfortunately swallowed by this wrap).","triggerScenarios":"Schema export/update at startup inside a runtime whose JTA TransactionManager is broken, still initializing, shutting down, or in an inconsistent state, so suspend() raises SystemException.","commonSituations":"Narayana/Atomikos misconfiguration (corrupted object store, recovery manager not ready); deployment-time schema work racing TM startup or shutdown; TM/Hibernate version pairings that were never tested together.","solutions":["Check the TransactionManager's own logs for the underlying suspend failure and its error code","Run DDL before the JTA runtime starts or after it is fully healthy (external migration tool)","Repair the JTA runtime configuration (object store, recovery ports) and retry startup","Workaround: execute the schema update with a non-JTA (resource-local) configuration"],"exampleFix":"// before\nprops.put(\"hibernate.hbm2ddl.auto\", \"update\"); // DDL runs through a broken JTA TM at boot\n\n// after\n// migrate before the app/TM boots, then only validate:\nprops.put(\"hibernate.hbm2ddl.auto\", \"validate\");","handlingStrategy":"try-catch","validationCode":"// fail fast if the TM is not operational before triggering DDL\ntry {\n  Transaction suspended = transactionManager.suspend();\n  transactionManager.resume(suspended); // probe round-trip\n} catch (Exception probe) {\n  throw new IllegalStateException(\"JTA TM not healthy; do not run DDL isolation\", probe);\n}","typeGuard":null,"tryCatchPattern":"catch (org.hibernate.HibernateException e) {\n  // suspend failed at the JTA level: check TM logs/error codes, repair the TM config,\n  // or rerun DDL with a resource-local configuration — do not retry in the same state\n}","preventionTips":["Ensure the JTA runtime is fully started before schema tools run","Externalize DDL to migration tooling that runs outside JTA","Keep TM and Hibernate versions on tested combinations"],"tags":["hibernate","jta","ddl","transaction-suspend"],"backgroundTag":"jta-transaction-suspend-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}