| 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: 210
|
|
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.
|
 |
 |
|
|
subject: System Exceptions and bean instances
|
|
|