ejb@glassfish.java.net

Re: An EJB 3.0 question

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Thu, 09 Feb 2006 10:06:21 -0500

Vikas Awasthi wrote:

> Hi Ken,
>
> Here is a text from section 4.6.7 of EJB 3.0 (Core) specification-
> "All the exceptions defined in the throws clause of the matching
> method of the session bean class must be defined in the throws clause
> of the method of the remote interface."
>
> Another text from section 13.2.1 of same specification is -
> "An application exception that is an unchecked exception is defined as
> an application exception by annotating it with the
> ApplicationException metadata annotation, or denoting it in the
> deployment descriptor with the application-exception element."
>
> My question is -
> Is it legal if a business method in bean class throws an unchecked
> exception (not marked as ApplicationException) and the matching method
> in remote interface does not throw it? If it is legal then the text in
> section 4.6.7 is wrong. Pls refer to the pseudo code at the end of
> this email for details.
> Will it be correct to have a verifier assertion like-
> "All the exceptions defined in the throws clause of the matching
> method of the session bean class, excluding unchecked exceptions *not*
> marked as ApplicationException, must be defined in the throws clause
> of the method of the remote interface."

Not sure what the intent was in the spec. From a language perspective,
there's no advantage to putting the unchecked exceptions in the
signature since the compiler
doesn't use them in its caller-side exception checking. However, from
a style perspective it's
important since the operation is assigning special semantics to an
exception,
which is something the caller should be as aware of as possible.

Just want to note that the sections you referenced explicitly deal with the
Remote case, but the same issues apply to the local case as well.

Linda, can you clarify this?


>
>
>
> thanks,
> Vikas.
>
> /RemoteIntf:
> /public class MyRemote {
> void foo() throws MyException;
> }
>
> /Bean Class:
> /_at_Remote(MyRemote.class)
> public class MyBean {
> void foo() throws MyException, NullPointerException {}
> }
>