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();
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");
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
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