Two Laptop Bag*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes query on enthuware mock exam  question related to exception handling in MDB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "query on enthuware mock exam  question related to exception handling in MDB?" Watch "query on enthuware mock exam  question related to exception handling in MDB?" New topic
Author

query on enthuware mock exam question related to exception handling in MDB?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

a question from enthuware mock kit has an option that goes like this. We have to choose correct.

OPTION A - onMessage() of a Message Driven Bean is not allowed to throw application exceptions.

EXPLANATION : It can throw application exceptions. However, since onMessage() cannot throw checked exceptions, the only way to throw an application is to throw a subclass of RuntimeExcecption and annotate with @ApplicationException.


can we apply the same explanation for lifecycle callback interceptor methods ? why ?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

can we apply the same explanation for lifecycle callback interceptor methods ?

A MDB is not allowed to throw an Application Exception from a lifecycle callback interceptor method.

14.3.5 Exceptions from PostConstruct and PreDestroy Methods of a Message-Driven Bean
Bean method condition | Bean method exception | Container action
Bean is message-driven bean | System exceptions | Log the exception or error. Discard instance.


In fact all lifecycle callback methods (not only for MDB's) are not allowed to throw an application exception. (check the table ch. 6.4 Handling of exceptions in my notes)

Regards,
Frits
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: query on enthuware mock exam question related to exception handling in MDB?