79684615

Date: 2025-06-30 10:24:43
Score: 1.5
Natty:
Report link

I found a working solution. Liberty 23.x does not expose TransactionManager over JNDI, you need to use reflection to obtain TransactionManager.

This bean definition helped me configure JtaTransactionManager.

    @Bean
    public JtaTransactionManager transactionManager() throws Exception {
        InitialContext context = new InitialContext();

        UserTransaction utx = (UserTransaction) context.lookup("java:comp/UserTransaction");

        TransactionManager ibmTm = (TransactionManager) Class
            .forName("com.ibm.tx.jta.TransactionManagerFactory")
            .getDeclaredMethod("getTransactionManager")
            .invoke(null);

        return new JtaTransactionManager(utx, ibmTm);
    }

I found the answer here: https://stackoverflow.com/a/79363034/30908754

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Emma