users@glassfish.java.net

Transaction Question

From: <glassfish_at_javadesktop.org>
Date: Mon, 30 Nov 2009 16:29:44 PST

I have a stateless session bean. It has a method exposed by a local
interface. The method performs several database operations, searches,
updates, inserts, etc. Before the method returns, it calls the timer
service to create a timer. When the timer service is called, I get this:

TransactionRollbackException: Client's Transaction aborted

My understanding is that while using JTA, a transaction is started when
the method is called and committed when it returns. However, the timer
service call is not part of the transaction and it causes the existing
transaction to stop and rollback. I tried joining the transaction using
this code:

@Resource
UserTransaction utx;

EntityManagerFactory emf = Persistence.getEntityManagerFactory("PU");
EntityManager em = emf.createEntityManager();
utx.begin();
em.joinTransaction();
timerService.createTimer(...);

However, after trying this I get this:

IllegalStateException: Operation not allowed

Nothing I try seems to work.

A few questions:
- Is this analysis correct?
- How can I solve this problem? It doesn't really matter to me if the
existing JTA transaction is committed or the timer service call is added
to the transaction (though I would prefer the latter).
- Where can I find more information to understand how the transaction
system works in GF? The documentation seems scattered.

Thanks,
Darryl
[Message sent by forum member 'dmocek' ]

http://forums.java.net/jive/thread.jspa?messageID=373963