0
votes

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" />
1

1 Answers

0
votes

We had introduced the tomcat-jta module to help integrating with the tomcat since the Narayana 5.5. See https://github.com/jbosstm/narayana/tree/master/tomcat so I think you need to use the following context.xml

<!-- Narayana resources -->
<Transaction factory="org.jboss.narayana.tomcat.jta.UserTransactionFactory"/>
<Resource name="TransactionManager" type="javax.transaction.TransactionManager"
          factory="org.jboss.narayana.tomcat.jta.TransactionManagerFactory"/>
<Resource name="TransactionSynchronizationRegistry" type="javax.transaction.TransactionSynchronizationRegistry"
          factory="org.jboss.narayana.tomcat.jta.TransactionSynchronizationRegistryFactory"/>