[jboss-user] [EJB 3.0] - Re: Should unchecked, but declared exceptions get wrapped in

cracru do-not-reply at jboss.com
Tue Apr 17 18:46:56 EDT 2007


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



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038174#4038174

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4038174



More information about the jboss-user mailing list