users@glassfish.java.net

Re: java.lang.IllegalStateException for Transaction

From: <glassfish_at_javadesktop.org>
Date: Mon, 21 Jul 2008 17:58:28 PDT

> Curiouser and curiouser.

Yes, indeed :)

>
> - Servlet calls SLSB to update domain object
> - JPA looks up sequence info, and send an INSERT to
> the DB.

This is part of the normal tx, right? Do you call em.flush() to force the insert?

> - TransactionSyncrhonizer.beforeComplete fires, and
> sends auditing info to a different SLSB

It should call the same instance that has been registered with the transaction Synchronization. It might not be the right choice to register a SLSB as it has lifecycle that is managed by the container, so it can be serving another request at the time of the callback...

> - At that point, I hit the JPA to do a lookup,

What kind of lookup is it?

and
> the JPA tries to write my original domain object to
> the DB again, and I get a duplicate insert error.

This is strange (that the insert is duplicated) - can it be that your insert method is executed again?

>
> Note, this was happening in a normal everyday
> transaction, not within the multiple REQUIRES_NEW
> transactions of the original issue.

OK.

thanks,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]

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