Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFEJB final Mock Question on exception

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFEJB final Mock
Page 679
Q 67
If a bean catches a checked exception, from which it can not recover, what should it do?

c. Regardless of the client, throw a javax.ejb.EJBException
d. Regardless of the client, propogate the same exception to the container

Correct answer given is C.

I answered D, since checked excpetion = application exception.
What am I missing?

Thanks,
Gemini
[ April 03, 2005: Message edited by: Gemini Moses ]
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is stated in the EJB 2.0 specifications on how to handle such situation whereby the bean encountered a checked exception & it cannot recover. Check out page 373. The 2nd bullet point clearly states what it should do: throw EJBException that wraps the original.

You should read the specifications if you wish to do well in the exams. It really helps a lot. I think this was also mentioned in the HFEJB book somewhere, although I can't give you the exact page number off-hand.
[ April 04, 2005: Message edited by: Chengwei Lee ]
 
David Gadd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the spec on page 373, and I re-read the information on application exceptions in HFEJB on page 541.

I believe that the mock exam question #67 is unfortunately ambiguous, because it doesn't state whether the checked exception we are talking about is DECLARED IN THE METHOD SIGNATURE.

If it is NOT declared in the method signature, AND it is a checked exception that is not recoverable, then yes, it makes sense and concurs with page 373 of the spec that it should be wrapped in EJBException (answer c). BUT if the checked exception IS DECLARED, and it is not recoverable, then just propagate that same exception to the container (answer d).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic