Well...First of all it's never
recommended to through a RuntimeException explicitly, as it indicates the
state that'll eventually lead into the application termination (and if the
programmer is able to restore the application state he would better through an
Application exception). However still there might be some very critical cases
where one is forced to use it.
Now coming to your question, not
every subclass of the "Exception" is treated as the "Application Exception" but
the one that the user has explicitly derived from "Exception" (or from a
subclass Application Exception e.g. CreateException, FinderException). Because
if one inherits a "Custom Exception" class from "RuntimeException" class (that's
itself inherited from "Exception" class) or a subclass of it e.g.
EJBException, then that is treated as a system exception. And similarly the
scope of the "throws clause" is limited to the specific method but not to the
whole class (or a subclass).
Thanks
Zahid.
----- Original Message -----
From: Bryan Pendleton <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 03, 2001 3:20
AM
Subject: Can a RuntimeException ever be an
Application Exception?
>
> I am having a bit of trouble understanding the rules
> in chapter 12 of the EJB 1.1 spec.
>
> Specifically, I declared a method on my Remote Interface,
> and caused that method to throw a RuntimeException, and
> my app server appeared to treat my RuntimeException as
> a System Exception.
>
> THEN, I added the line:
>
> throws Exception
>
> to my method on my Remote Interface and my Bean Class.
> This was the only change I made to my test setup.
>
> When I added "throws Exception" to my method, my app server's
> behavior changed, and it treated the RuntimeException
> as an Application Exception.
>
> So my question is: if I state "throws Exception" on my
> Remote Interface method, does that make *every* subclass
> of Exception into an Application Exception, including
> RuntimeException? Or is RuntimeException always supposed
> to be special-cased?
>
> thanks,
>
> bryan
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>
