This content has been marked as final.
Show 1 reply
-
1. Re: Should unchecked, but declared exceptions get wrapped in
cracru Apr 17, 2007 6:46 PM (in response to cracru)The spec lead at Sun was kind enough to answer my question. Here's the results:
Of course, the JBoss implementation is operating per design and spec.
This means, all unchecked (and extending RuntimeException) exceptions that are not in the control of the business method developer, should not be included in the throws clause of a business method.
For example, don't do this in the SLSB:public void findWidget (Integer widgetId) throws javax.persistence.EntityNotFoundException
Doing so, makes for a confusing contract with the client. In the example the EntityNotFoundException will be treated as a system exception and wrapped with EJBException before it is passed to the client.
If you own the exception, you can annotate with @ApplicationException. Otherwise, you have two choices:
- catch, wrap, and throw your own exception
- use application-exception deployment descriptor to affect all occurrences of the exception