users@glassfish.java.net

Re: Transaction Question

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 30 Nov 2009 18:07:48 -0800

Timer creation is part of the transaction. So if transaction is aborted, the
timer won't be created.

If there is a problem with creating a timer, there should be some kind of an
exception that you get (and logged in the server.log).

You are not allowed to use UserTransaction in an EJB with the container-managed
transaction.

-marina

glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>