• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction confusion

 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out when a client would actually get back a TransactionRolledbackException or TransactionRolledbackLocalException.
Here's a scenario that I'm wondering about:
CMT is used. A client with an existing transaction calls a method on a bean that has a Required transaction attribute and so the method runs in the client's transaction. The bean method throws a null pointer exception. Will the client stack trace show a TransactionRolledbackException for a remote call or a NullPointerException or both?
Could a client get a TransactionRolledbackException in a situation other than the above scenario?
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CMT is used. A client with an existing transaction calls a method on a bean that has a Required transaction attribute and so the method runs in the client's transaction. The bean method throws a null pointer exception. Will the client stack trace show a TransactionRolledbackException for a remote call or a NullPointerException or both?
Could a client get a TransactionRolledbackException in a situation other than the above scenario?

If setRollbackOnly() is called before system exception (nullpoint or any unexpected exception) then method won't throw TransactionRollbackedException().
If setRollbackOnly() isn't define in that case remote method call will get TransactionRolledbackException(). Remember remote client get RemoteException() for any system exception throw at server side and those are never pass as it is by server. (only application exception are pass as its by server to client).
Also refer page number 551 from Head First EJB for exception hierarchy.
Hope this help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic