• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic