If the bean runs in a tx context of the caller (and thus have a tx attribute of Mandatory, Required or Supports) and the bean throws a system exception, the (remote) client gets a TransactionRolledBackedException (which is a subclass of RemoteException). However, if the bean does not throw a system exception but calls ctx.setRollbackOnly() instead (making the transaction doomed to eventually rollback), the client does not get an exception other than a possible application exception thrown directly from the bean class. So, the 1 would be right in the context of client started transaction (because the container throws a TransactionRolledbackException not RemoteException).
BUT, if the bean starts a new transaction (and thus has a tx attribute of RequiresNew) and the container rolls back the transaction for any reason, the client gets a RemoteException (making the 1 incorrect).
Same also applies to local clients, but exceptions are different (TransactionRolledbackLocal and EJBException).
Originally posted by Li Xin:
Which of the following statements are true when a session bean's client receives a java.rmi.RemoteException? [Check all correct answers]
1. The container does not throw the java.rmi.RemoteException if the container performs a transaction rollback.
2. The client will never receives a java.rmi.RemoteException.
3. The client calls the session bean from another JVM.
4. The client calls the session bean from within the same JVM.
5. The throws clauses of all methods in the remote home and component interface must declare a java.rmi.RemoteException.
The provided answer is 1, 3 and 5, I don't understand why 1 is correct, can anyone explain?
Thanks!