File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes system exceptions 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 "system exceptions" Watch "system exceptions" New topic

system exceptions

sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
I came across this question in ejbcertificate mock exam
Which of the following statements regarding message-driven bean exception handling are true?
1. Message-driven beans throw both application exceptions and system exceptions.
2. If a system exception is thrown by a method, the transaction is always rolled back by the container.
3. If a system exception is thrown by a method, the bean instance is always discarded.
4. If a system exception is thrown by a method, the client does not receive the exception.
5. If an application exception is thrown by a method, the client receives the exception.
Answer given: 3, 4.
I did not understand why option 4 is correct. I thought the client will receive a EJBException/RemoteException when a system exception occurs.
Jack Zhou
Ranch Hand

Joined: Dec 27, 2003
Posts: 93
MDB does not have a client.

Thanks,<br />Jack Zhou<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS,SCEA
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The client knows nothing of the MDB as it only talks to the Destination. When an MDB method throws an exception, the container will always log the exception, rollback the transaction (if necessary) and destroy the MDB instance.
Should the client then send another message to the Destination, the container can pull another MDB instance from the pool to service the message.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
MDB can throws System exception only.
MDB can not throws application exception and can not throws exception to client because MDB don't have any client.
MDB run in CMT
CASE 1 : Bean method runs in the context of a transaction that the Container started immediately before dispatching the method. This case happens with
Required attribute.
This method is throws System exception
In Container
Log the exception or error.
Rollback the container-started transaction.
Discard instance.
Case 2 : Bean method runs with an unspecified transaction context.
This case happens with the NotSupported.
This method is throws System Exception.
In container
Log the exception or error.
Discard instance.
MDB run in BMT
Bean is message-driven bean.
If this method is throws System exception
Log the exception or error.
Mark for rollback a transaction that has been started, but not yet completed, by the instance.
Discard instance.

Java Developer, Thailand
I agree. Here's the link:
subject: system exceptions
It's not a secret anymore!