Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question from ejbcertificate.com

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Right! We're on it! Let's get to work tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic