"Know where to find the solution and how to use it - that's the secret of success."
"Know where to find the solution and how to use it - that's the secret of success."
Amirr Rafique wrote:Hello
Can an MDB throw an application exception ?
Thanks
SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
"Know where to find the solution and how to use it - that's the secret of success."
The onMessage() method can throw only RuntimeExceptions therefore bean provider may throw an @ApplicationException which is the java.lang.RuntimeException.
SCJP 6, SCWCD 5, SCBCD 5
From my studying, if a RuntimeExceptions that is defined as application exception using @ApplicationException, that exception need to be either declare in the throws clause of the bean method or catch in the bean method. As referring to the rules of exception handling that "you cannot throw any checked Exceptions other than those declared in the method you are overriding", so in your bean class which override the onMessage() method cannot declare additional exception in the throws clause, so if inside the onMessage() method do receive a ducking application exception from the method invoked from onMessage() method, it need to be catch. Am I right ?
"Know where to find the solution and how to use it - that's the secret of success."
I think here you are referring to exceptions extending java.lang.Exception class and marked as @ApplicationException. As any exceptin extending RuntimeException does not need to be declare in throws clause
Please confirm
SCJP 6, SCWCD 5, SCBCD 5
"Know where to find the solution and how to use it - that's the secret of success."
My understanding is for RuntimeException, it is not required to be mentioned in throws clause whether it is annotated as @ApplicationException or not
Please correct me
SCJP 6, SCWCD 5, SCBCD 5
Amirr Rafique wrote:My understanding is for RuntimeException, it is not required to be mentioned in throws clause whether it is annotated as @ApplicationException or not
Please correct me
SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
Your onMessage method should handle all exceptions. It must not throw checked exceptions, and throwing a RuntimeException is considered a programming error.
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|