I switched from Hibernate 4.2 to Hibernate 4.3 and my project is not working any more. I\'m getting an
HibernateException: Unable to locate current JT
The following is an alternative approach that works with Spring configuration. This is different from Anton's approach in that is does not rely on instance method writes to a static field (which is generally considered bad practice).
@SuppressWarnings("serial")
public class AtomikosJtaPlatform extends AbstractJtaPlatform {
private static TransactionManager transactionManager;
private static UserTransaction userTransaction;
public static void factoryInit(TransactionManager transactionManager, UserTransaction userTransaction) {
AtomikosJtaPlatform.transactionManager = transactionManager;
AtomikosJtaPlatform.userTransaction = userTransaction;
}
@Override
protected TransactionManager locateTransactionManager() {
return transactionManager;
}
@Override
protected UserTransaction locateUserTransaction() {
return userTransaction;
}
}
Then in Spring configuration:
com.mycompnay.a.b.AtomikosJtaPlatform
...