• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Question from ejbcertificate.com

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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
  • 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!

 
I found a beautiful pie. And a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!