2

I'm developing a application with JPA(Hibernate) as backend. I have a DAO and JPADAO for each entity and my process updates more than one entity as one unit of work, so I decided to use JTA as it allows me to control the transactions so here's how my code looks persistence.xml

    <persistence-unit name="Pub" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:comp/env/jdbc/dcapps</jta-data-source>

     <property name="hibernate.dialect" value="org.hibernate.dialect.InformixDialect"/>
        <property name="transactionSynchronizationRegistryName" value="java:comp/env/TransactionSynchronizationRegistry"/>
        <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JOTMJtaPlatform"/>


            web.xml
      <resource-ref>
  <description>DB Connection</description>
  <res-ref-name>jdbc/dcapps</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>

<resource-env-ref>
<description>JTA transaction manager</description>
<resource-env-ref-name>jta/UserTransaction</resource-env-ref-name>
<resource-env-ref-type>javax.transaction.UserTransaction</resource-env-ref-type>
</resource-env-ref>

    <resource-env-ref>
<description>JTA Transaction Synchronization Registry</description>
<resource-env-ref-name>TransactionSynchronizationRegistry</resource-env-ref-name>
<resource-env-ref-type>javax.transaction.TransactionSynchronizationRegistry
 </resource-env-ref-type>
 </resource-env-ref>


         content.xml(Tomcat 7)
        <Resource name="jdbc/dcapps" auth="Container" type="javax.sql.DataSource"
               maxActive="20" maxIdle="10" maxWait="-1"
               username="dcapps" password="dcapps" driverClassName="com.informix.jdbc.IfxDriver"
               url="jdbc:informix-sqli://fddb.fd.gtwy.dcn:7101/fd_test:INFORMIXSERVER=fd_ecf"/>

 <Resource
        name="TransactionSynchronizationRegistry"
        auth="Container"
        type="javax.transaction.TransactionSynchronizationRegistry"
        factory="org.objectweb.jotm.TransactionSynchronizationRegistryFactory"/>

<Transaction
        factory="org.objectweb.jotm.UserTransactionFactory"
        jotm.timeout="60"/>





        Process.java
       Context initContext = new InitialContext();
     utx  = (UserTransaction)initContext.lookup("java:comp/UserTransaction");
             dktPartDAO.getEntityManager().joinTransaction();
            dkttextDAO.getEntityManager().joinTransaction();
            reqHDAO.getEntityManager().joinTransaction();
            reqDDAO.getEntityManager().joinTransaction();
            costDAO.getEntityManager().joinTransaction();
            reportDDAO.getEntityManager().joinTransaction();
            caseflagDAO.getEntityManager().joinTransaction();
            redStatusDAO.getEntityManager().joinTransaction();
            pcdktPartDAO.getEntityManager().joinTransaction();
            pcDkttextDAO.getEntityManager().joinTransaction();
                           utx.commit();

Now when I try to begin a transaction and commit changes to the entities(more than one) then it throws and exception and calls the utx.rollback but it will not rollback it has commited the transaction only partially not all entities are saved

         Exception
      java.lang.IllegalStateException: Cannot get Transaction for rollback
at org.objectweb.jotm.Current.rollback(Current.java:486)
at pub.jpa.dto.support.PubDProcess.processRecords(PubDProcess.java:397)

         org.omg.CORBA.BAD_INV_ORDER: The Servant has not been associated with an ORB instance  vmcid: 0x0  minor code: 0  completed: No
at org.omg.PortableServer.Servant._get_delegate(Unknown Source)
at org.omg.PortableServer.Servant._poa(Unknown Source)
at org.objectweb.jotm._SubCoordinator_Tie.deactivate(Unknown Source)
at com.sun.corba.se.impl.javax.rmi.CORBA.Util.cleanUpTie(Unknown Source)
at com.sun.corba.se.impl.javax.rmi.CORBA.Util.unexportObject(Unknown Source)
at javax.rmi.CORBA.Util.unexportObject(Unknown Source)
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.unexportObject(Unknown Source)
at javax.rmi.PortableRemoteObject.unexportObject(Unknown Source)
user2250679
  • 43
  • 2
  • 5

1 Answers1

1

You do not mention which version of JOTM you're using, but I encountered the exact same issue using v2.2.1. Downgrading to version v2.1.9 fixed the issue for me.

Apparently it has been fixed recently, see http://websvn.ow2.org/comp.php?repname=jotm&compare[]=/@1174&compare[]=/@1175

With kind regards,

Barry

blagerweij
  • 3,154
  • 1
  • 15
  • 20