{"record":{"id":"ccbb718a94f9b2f6","repo":"flowable/flowable-engine","slug":"systemexception-while-marking-transaction-rollback","errorCode":null,"errorMessage":"SystemException while marking transaction rollback only","messagePattern":"SystemException while marking transaction rollback only","errorType":"exception","errorClass":"org.flowable.common.engine.api.FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/cfg/jta/JtaTransactionContext.java","lineNumber":58,"sourceCode":"\n    @Override\n    public void commit() {\n        // managed transaction, ignore\n    }\n\n    @Override\n    public void rollback() {\n        // managed transaction, mark rollback-only if not done so already.\n        try {\n            Transaction transaction = getTransaction();\n            int status = transaction.getStatus();\n            if (status != Status.STATUS_NO_TRANSACTION && status != Status.STATUS_ROLLEDBACK) {\n                transaction.setRollbackOnly();\n            }\n        } catch (IllegalStateException e) {\n            throw new FlowableException(\"Unexpected IllegalStateException while marking transaction rollback only\", e);\n        } catch (SystemException e) {\n            throw new FlowableException(\"SystemException while marking transaction rollback only\", e);\n        }\n    }\n\n    protected Transaction getTransaction() {\n        try {\n            return transactionManager.getTransaction();\n        } catch (SystemException e) {\n            throw new FlowableException(\"SystemException while getting transaction \", e);\n        }\n    }\n\n    @Override\n    public void addTransactionListener(TransactionState transactionState, final TransactionListener transactionListener) {\n\n        Transaction transaction = getTransaction();\n        CommandContext commandContext = Context.getCommandContext();\n        try {\n            transaction.registerSynchronization(new TransactionStateSynchronization(transactionState, transactionListener, commandContext));","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/cfg/jta/JtaTransactionContext.java#L40-L76","documentation":"Flowable's JTA transaction context wraps Transaction.setRollbackOnly() and translates javax.transaction.SystemException into this FlowableException. SystemException indicates the transaction manager itself failed (a low-level, unexpected error in the JTA implementation) while trying to mark the transaction rollback-only.","triggerScenarios":"Calling rollback() when the underlying TransactionManager/Transaction implementation throws SystemException from setRollbackOnly() — e.g. TM internals failure, corrupted transaction state, or resource manager errors surfaced as SystemException.","commonSituations":"Application server transaction service failures; misconfigured TransactionManager (wrong JNDI lookup / multiple TM instances); known bugs in older app server JTA implementations; resource adapter failures propagating SystemException.","solutions":["Inspect the wrapped cause (getCause()) for the real transaction-manager failure and fix that underlying problem first.","Verify the TransactionManager configuration: the JtaTransactionContextFactory must be wired to the app server's TransactionManager (correct JNDI name or managed bean).","Upgrade/patch the application server or JTA implementation if the SystemException is a known TM bug.","Check resource managers (datasources, JMS) for failures that propagate as SystemException during rollback.","Retry the command in a fresh transaction; if the TM is degraded, restarting the server/container may be required."],"exampleFix":"// before: custom TransactionManager lookup returning wrong instance\nTransactionManager tm = (TransactionManager) ctx.lookup(\"java:comp/TransactionManager\");\n// after: use the container-provided manager appropriate to the server\nTransactionManager tm = (TransactionManager) ctx.lookup(\"java:jboss/TransactionManager\");","handlingStrategy":"try-catch","validationCode":"try { tm.getTransaction(); } catch (SystemException e) {\n  throw new IllegalStateException(\"Transaction manager unhealthy: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runtimeService.startProcessInstanceByKey(\"p\");\n} catch (FlowableException e) {\n  if (e.getCause() instanceof SystemException) {\n    log.error(\"JTA TM failure\", e.getCause());\n    // alert/retry; possibly restart TM\n  } else throw e;\n}","preventionTips":["Verify TransactionManager wiring (JNDI name / managed bean) at startup with a smoke test.","Monitor app-server transaction service health.","Keep app server and JTA implementation patched for known SystemException bugs.","Check datasources/resource adapters for failures that surface as SystemException."],"tags":["jta","transaction","system-exception","flowable"],"backgroundTag":"upstream-api-error","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}