Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
rituraj_tiwari Mar 19, 2008 11:25 PMFolks,
I am at my wit's end with this problem. My application has an EndUser entity fronted by an EntityHome class which is injected into the session upon successful authentication. My application has an edit profile page that lets the end user change attributes about their profile. This page makes use of AJAX: DHTML + Seam Remoting.
The first hurdle I cleared was to make sure that the Seam Remote calls use the same conversation as the rest of the page. Otherwise, the entity manager injected into EndUserHome was appearing closed. This was done using:
Seam.Remoting.getContext().setConversationId(#{conversation.id});
With this, my AJAX calls to fetch the profile started working. The problem now is that if I try to change anything in the profile, the calls fail on the server with this:
Caused by: java.lang.IllegalStateException: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml at org.jboss.seam.transaction.SeSynchronizations.registerSynchronization(SeSynchronizations.java:57) at org.jboss.seam.transaction.UTTransaction.registerSynchronization(UTTransaction.java:92) at org.jboss.seam.async.AbstractDispatcher.scheduleTransactionSuccessEvent(AbstractDispatcher.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I searched the web and found advise to set this in my components.xml:
<transaction:ejb-transaction/>
however, this leads to parse errors in my components.xml.
If I fix the parse errors by adding xmlns:transaction="http://jboss.com/products/seam/transaction" to my components.xml, I get all kinds of errors pop up on the server as soon as the application is accessed.
I have also tried setting the JPA RESOURCE_LOCAL transactions by setting:
<transaction:entity-transaction entity-manager="#{entityManager}"/>
This shows errors similar to the ones encountered with the ejb-transaction setting:
Caused by: java.lang.IllegalStateException: JTA EntityManager cannot access a transactions at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:316) at org.jboss.seam.persistence.EntityManagerProxy.getTransaction(EntityManagerProxy.java:110) at org.jboss.seam.transaction.EntityTransaction.getDelegate(EntityTransaction.java:61) at org.jboss.seam.transaction.EntityTransaction.begin(EntityTransaction.java:81) at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:566)
My environment is JBoss 4.2.2GA and Seam 2.0.0GA.
Any help is greatly appreciated.
Thanks.
-Raj