[jboss-user] [EJB 3.0] - Bean Managed Transaction: No JTA transaction found
rituraj_tiwari
do-not-reply at jboss.com
Sat May 24 16:00:14 EDT 2008
I am resorting to BMT due to the need to launch persistence operations in worker threads.
I am using the BMT format as described here http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/transactions.html
So, I have
| @PersistenceUnit EntityManagerFactory m_emf;
| @Resource UserTransaction m_ut;
|
And my worker threads do the equivalent of
| public Result call() {
| EntityManager em = factory.createEntityManager();
| try {
|
| // do some work
| ...
|
| m_ut.commit();
| }
| catch (RuntimeException e) {
| if (m_ut != null) m_ut.rollback();
| throw e; // or display error message
| }
| finally {
| em.close();
| }
|
I observe that any entities I create aren't being written to the database. Looking in JBoss logs from the EntityManager creation point, I see:
| 2008-05-24 12:39:10,911 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2008-05-24 12:39:10,911 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] No JTA transaction found
|
Also, When I look at what happens when I am creating and persisting entities, I see:
| 2008-05-24 12:40:05,036 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] delaying identity-insert due to no transaction in progress^M
|
Am I making some obvious mistake? Is launching persistent operations from separate threads not supported?
Thanks.
-Raj
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4153175#4153175
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4153175
More information about the jboss-user
mailing list