File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Handling Exceptions + HFE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Handling Exceptions + HFE" Watch "Handling Exceptions + HFE" New topic
Author

Handling Exceptions + HFE

cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
Hi,
I just would like to point out that concerning handling system exceptions, HFE p.546 is perhaps not enough precise.
It is said that in this case, the transaction is generally rolled back.
But of course, it depends on the existence of a transaction context.
By example, for message driven bean's method running in NOT SUPPORTED transaction attribute, if a system exception is thrown, no transaction rollback happens and only exception logging + discarding instance do happen.
It would have been great to detail more the scenario dealing with the different transaction contexts.
By example, with MANDATORY transaction attribute for a session or entity bean, in case of system exception, a TransactionRolledbackException (Remote) or TransactionRolledbackLocalException(Local) should be thrown by the container whereas in case of REQUIRESNEW, only RemoteException(Remote) or EJBException (Local) will be sent...
All this is detailed p.375-p.378 of the EJB 2.0 spec.
It doesn't change anything to the fact that HFE is really a excellent book;-)
REgards,
Cyril.
[ April 11, 2004: Message edited by: cyril vidal ]

SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Actually, I was thinking of this very subject today. It would also have been good if the book had contrasted the handling of exceptions thrown by a business method of a bean with container-managed transaction with what happens when a client calls a bean which has an invalid transaction attribute. This is what I am thinking of.
If the client calls a bean (whose transaction attribute is set to Mandatory) without a transaction context, the Container throws the javax.transaction.TransactionRequiredException exception if the client is a remote client, or the javax.ejb.TransactionRequiredLocalException if the client is a local client.
If the client calls a bean (whose transaction attribute is set to Never) with a transaction context, the Container throws the
java.rmi.Remote-Exception exception if the client is a remote client, or the javax.ejb.EJBException if the client is a local client.

[ April 11, 2004: Message edited by: Roger Chung-Wee ]

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
Hi,

If the client calls a bean (whose transaction attribute is set to Mandatory) without a transaction context, the Container throws the javax.transaction.TransactionRequiredException exception if the client is a remote client, or the javax.ejb.TransactionRequiredLocalException if the client is a local client.

Actually, HFE told about this. cf p.558 in the transaction scenario:
Client calls a method on a Remote CMT bean, and the method is marked Mandatory. The caller does not have a transaction context in place when the call comes in
The client gets a TransactionRequiredException (a local client would get a TransactionRequiredLocalException).
Regards,
Cyril.
[ April 12, 2004: Message edited by: cyril vidal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling Exceptions + HFE
 
Similar Threads
HFE + SessionSynchronization
system exceptions + CMT or BMT
page 561 exercise question
Some questions about transactions and reentrancy
System exception in a BMT