Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception qustion in HFEJB

 
Shiang Wang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page. 564 #4
Which of the following are EJB 2.0 specification guidelines regarding system exception?
.
.
B. Bean methods should wrap unrecoverable checked exception in a javax.ejb.EJBException exception.
C. For remote clients, bean methods should wrap unrecoverable checked exception in a java.rmi.RemoteException.

Answer is B only.

Why c is not correct? I know checked exception includes RemoteException, and container will handle that, no problem here. But there might not other unrecoverable checked exceptions, you will want to let container handle the rollback, clean up process by wrapping them up as RemoteException. :roll:

Thanks
Shiang
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As of the EJB 2.0 specification, the bean methods are not allowed to declare (and throw) RemoteException anymore. Check out section 18.2.2 (System exceptions) of the EJB 2.0 specification which clearly explains how beans should process unrecoverable error conditions.
 
Shiang Wang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I was confused by the role of bean provider and the client. Bean providers should wrap it up as EJBException NO MATTER WHAT, clients will receive them differently depends on whether it is remote or local.

Shiang
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!