users@glassfish.java.net

Glassfish does NOT do transactions?

From: <glassfish_at_javadesktop.org>
Date: Tue, 14 Oct 2008 15:01:01 PDT

(Yeah, the subject line is deliberately provocative, but then after 4 full days of frustration on this I'm pretty provoked myself right now.)

We cannot get database-level transactions to work with Glassfish. Our scenario:

Using a Container Managed MessageDriven bean, we have:

  MessageDriven bean (called by JMS inside a JTA transaction)
      creates an object and...
      calls a Stateless Session bean, which does...
               em.persist(object)
               em.flush()
               return to Message Bean
  (pause the code and check the DB at this point - the object is visible to other processes
           even though the transaction has not been committed)
  setRollbackOnly()
  return


After this test, the object remains in the database, which is clearly wrong for operation within a transaction.

It is also incorrect that the object should be visible to other applications before the high-level JTA transaction has been completed.

While the JTA transaction probably works correctly, that is entirely useless if the database has been modified and cannot be rolled back when the JTA transaction needs to be rolled back.

This is exactly the scenario as discussed in
http://forums.java.net/jive/thread.jspa?threadID=25163&tstart=15
but no fix or work-around was forthcoming in that thread.

This is is such a huge failure for an application server that I have trouble believing that it works this way. I am desperately hoping that someone out there will be able to point out the (no doubt obvious) mistake we've made and tell us how to fix it.

I have attached appropriately summarized code fragments from the message bean and the Session bean.

Please tell me where I've gone wrong!
(and if that is not an open invitation for abuse, I don't know what would be :-) )

Thanks for your help.
[Message sent by forum member 'gwg' (gwg)]

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