javaspringspring-bootbitronix

Creating bitronix transaction manager in spring-boot


I am trying to create the spring-boot transaction manager bean as follows:

@Bean(destroyMethod="shutdown")
public static TransactionManager bitronixTransactionManager() {
    return TransactionManagerServices.getTransactionManager();
}

However I am getting:

java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
    at bitronix.tm.Configuration.checkNotStarted(Configuration.java:699)
    at bitronix.tm.Configuration.setServerId(Configuration.java:145)

I believe this is cause I am calling .getTransactionManager() myself.

However If i do not, how would I create the transaction manager.

The equivalent xml would be:

<bean id="bitronixTransactionManager" class="bitronix.tm.TransactionManagerServices" 
          factory-method="getTransactionManager" destroy-method="shutdown" depends-on="bitronixConfig" />

Solution

  • Bitronix support has been added to Spring Boot 1.2. You might want to give the latest snapshots a try. There is a sample application here.