5 Replies Latest reply on Sep 28, 2012 12:03 PM by Kevin Conner

    Commit in Actions

    Martin Fluegge Newbie

      Hi everbody,


      first let me say that I am a Jboss newby, so please don't hit me if it turns out that the answer to my question is quite obvious


      I started working with an existing apllication that bases on Jboss ESB. I was asked to maintain an action that writes data to the database. With my humble Hibernate knolede I started the following approach:


      session = sessionFactory.getCurrentSession();



      //modify data





      While the Jboss is configured to use several threads (2 in my case) I was wondering that a second instance of the action could not read the data from the db, although a commit was already performed in the first thread. Debugging this I found out that the commit on the transaction does not write the data, but this is somehow postponed, thus saving my commits using locks did not work.


      Second, I tried to use the userTransaction which is bound to the context of the Jboss.



      UserTransaction tx = (UserTransaction) new InitialContext().lookup("UserTransaction");



      //modify data





      In this case to commit was performed immediatelly, but an exception was thrown which I could not really google down.




      18:10:04,480 ERROR [JmsServerSession] org.jboss.resource.adapter.jms.inflow.JmsServerSession@758c5f failed to commit/rollback

      java.lang.IllegalStateException: Wrong tx association: expected TransactionImple < ac, BasicAction: 7f000101:ac13:5061d60b:176e status: ActionStatus.COMMITTED > was null

      at org.jboss.resource.adapter.jms.inflow.JmsServerSession$XATransactionDemarcationStrategy.end(JmsServerSession.java:467)

      at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:248)

      at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)

      at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)

      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:761)

      at java.lang.Thread.run(Thread.java:662)




      Has anyone an idea why the commit in the first approach is postponed. May there is something wrong configured. Or is this completely wrong and I should always use the user transaction?


      I was browsing the net for hald a day and did not really find a solution. It would be great if someone has an idea or could point me to a documentation.


      We are using Jboss 4.x



      Thanks in advance