• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

HFEJB final Mock Question on exception

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic