From https://github.com/jbosstm/narayana/, I have tried to use
org.jboss.narayana.jta:narayana-jta:5.6.2.Final
to implement JTA Transaction manager for Spring Data JPA (Hibernate) project.
Though Hibernate is successfully returning the object saved with the id(generated by Sequence), the row is not actually persisted in the database.
Any help will be more than welcome.
Spring config:
<jee:jndi-lookup id="userTxn" jndi-name="java:comp/UserTransaction" />
<jee:jndi-lookup id="tm" jndi-name="java:comp/env/TransactionManager" />
<jee:jndi-lookup id="jtaTxnSyncRegistry" jndi-name="java:comp/env/TransactionSynchronizationRegistry" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="userTxn"></property>
<property name="transactionManager" ref="tm"/>
<property name="transactionSynchronizationRegistry"
ref="jtaTxnSyncRegistry"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="entityManagerFactoryJTA" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceUnitName="myPU_JTA">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
</bean>
<jpa:repositories base-package="com.xxx.repository.jta"
entity-manager-factory-ref="entityManagerFactoryJTA"
transaction-manager-ref="transactionManager" />
context.xml of apache-tomcat-8.5.16:
<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction" factory="com.arjuna.ats.jta.TransactionManager" />
<Transaction factory="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple" /> <!-- auth="Container" -->
<Resource name="TransactionManager" auth="Container" type="javax.transaction.TransactionManager" factory="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple"></Resource>
<Resource name="TransactionSynchronizationRegistry" auth="Container" type="javax.transaction.TransactionSynchronizationRegistry"
factory="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple" />