This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Here is one of correct answer (according to enthu) for a question of enthu-ejb+ (Test 3, Q 23)
If it is a checked exception that is not listed in the throws clause of the method and if the bean cannot recover from this exception, the bean method should throw the javax.ejb.EJBException that wraps the original exception.
Dear Paul Anil, Can you (or your exam development team) please teach me how a method can throw checked exception without defining in throws clause.
Hello Chaminda, It will make sense if you read it in the presepective of what the question is asking, "What is the responsibility of the bean provider if his session bean method gets an exception during execution of its method body?"
Code within the method of a session bean may throw either a checked or an unchecked exception. It is not necessary that all the checked exceptions that are received while executing the method body are listed in the throws clause of the method. You can also put such a piece of code in a try-catch block. This is the scenario that the option you refered to is talking about. If you, as a bean developer, believe that such an exception is detrimental to the bean process and if you don't want to list that exception in the throws clause, you shoul throw an EJBException that wraps the original exception.
If you (or any one else readin this) have any thoughts how to reconstruct the option to avoid such confusion, please do share. We will really appreciate your feedback.