Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

HFEJB final Mock Question on exception

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?

[ April 03, 2005: Message edited by: Gemini Moses ]
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 ]
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).
brevity is the soul of wit - shakepeare. Tiny ad:
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
    Bookmark Topic Watch Topic
  • New Topic