wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes System Exceptions and bean instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "System Exceptions and bean instances" Watch "System Exceptions and bean instances" New topic
Author

System Exceptions and bean instances

Tyronne Fernando
Ranch Hand

Joined: May 11, 2008
Posts: 50
Hi,

Let's say Bean A invokes a method in Bean B. Bean B throws a System Exception. Does the container discard both Bean A and Bean B? Or it just discard the bean that gets a System Exception (Bean A) not the System Exception originator (Bean B)?

Does the above outcomes change depending on the bean type (session or message driven)?

Please let me know. Thanks in advance.

Cheers,
Tyronne
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
Please study the tables in EJB Core Spec Chapter 14 , it clearly state out all the circumstances for application exception and system exception.

For a short answer, Bean A is the client , Bean B is having the bean method invoked by client. When bean method throw System Exception, only the bean which bean method declared on is discarded by container, that is Bean B.

Bean A does get the exception, but it is not the system exception throw from Bean B, the exception get by Bean A is the exception throw by container, which is different depend on transaction context:
[the below is for session bean]
(1) For bean method which invoked in client transaction context
- EJBTransactionRollbackException (local client)
- TransactionRollbackException (remote client which extends Remote)
(2) For bean method which invoked in new transaction context
- EJBException
- RemoteException (remote client which extends Remote)
(3) For bean method which invoked in unspecified transaction context (means no transaction)
- EJBException
- RemoteException (remote client which extends Remote)

[check it out yourself , if the transaction is BMT ...... also put in some hardwork for MDB also]


Please study EJB Core Spec, All The Best ~ !!!


SCJP 6, SCWCD 5, SCBCD 5
Tyronne Fernando
Ranch Hand

Joined: May 11, 2008
Posts: 50
Thanks for the quick reply Lee.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System Exceptions and bean instances
 
Similar Threads
system exceptions
System Exceptions
What does really occur after a system exception?
MDB throw system exception
transaction doubt