You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Taylor <rt...@mulework.com> on 2002/08/06 21:06:43 UTC

Re: DispatchAction and declarative exception handling

Drew, I need to the do the same thing. Was the following issue ever
addressed? It seems like a fundemental problem with Struts1.1x exception
handling and DispatchAction/LookupDispatchAction. I'm a bit confused on your
solution, since dispatchMethod() only throws IOException. When I try the
same approach, I always get a compiler error complaining that the throws
clause is incompatible.

Am I missing something?

robert

BTW, I looked up the thread in the message archives and only found one
response (which was completely off topic).

-----Original Message-----
From: Drew McAuliffe [mailto:drew@lowerunit.com]
Sent: Saturday, July 20, 2002 3:03 AM
To: struts-user@jakarta.apache.org
Subject: DispatchAction and declarative exception handling


I'm not sure if this is intended behavior, but I've found what looks to
me like a problem with the DispatchAction class. In the "dispatchMethod"
method, exceptions are trapped and when they occur, are usually
processed by a call to "response.sendError()". This appears to bypass
any exception handling that might be configured declaratively. For
instance, if I have a login method on a subclass of "DispatchAction",
and it throws an "AuthenticationException", the dispathMethod will see
that as an InvocationTargetException and make a call to
"response.sendError()". So no matter how I've configured exceptions in
struts-config, I'll always get an error.

I would think that for at least "InvocationTargetException", this should
not be the way the exception is handled. I've modified my subclass of
DispatchAction to override "dispatchMethod". In my override, I treat
"InvocationTargetException" differently than the other trapped
exceptions. Because you'd usually reach this exception if there was an
exception in the action method, it will usually be a business exception
and not a system exception. My override pulls the cause exception out
("getCause") and throws it, rather than calling "response.sendError()"
and returning null. As a result, I can throw business exceptions in my
dispatchAction subclass methods and configure how they are handled in
the struts-config file.

Does this sound right, or am I missing something in how the
DispatchAction is supposed to be used?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: DispatchAction and declarative exception handling

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 6 Aug 2002, Robert Taylor wrote:

> Date: Tue, 6 Aug 2002 15:06:43 -0400
> From: Robert Taylor <rt...@mulework.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: Re: DispatchAction and declarative exception handling
>
> Drew, I need to the do the same thing. Was the following issue ever
> addressed? It seems like a fundemental problem with Struts1.1x exception
> handling and DispatchAction/LookupDispatchAction. I'm a bit confused on your
> solution, since dispatchMethod() only throws IOException. When I try the
> same approach, I always get a compiler error complaining that the throws
> clause is incompatible.
>
> Am I missing something?
>

For Struts 1.1, this was patched in version 1.9 of DispatchAction on
August 3.  Because LookupDispatchAction inherits the underlying
dispatchMethod() method, it inherits the revised behavior. All nightly
builds from 20020804 contain the change.

To research whether a change has actually been made or not, your best bet
is to search on the bug reports database
<http://nagoya.apache.org/bugzilla/> or browse the online CVS viewer for
the actual source code <http://cvs.apache.org/viewcvs/jakarta-struts/>.

> robert

Craig

>
> BTW, I looked up the thread in the message archives and only found one
> response (which was completely off topic).
>
> -----Original Message-----
> From: Drew McAuliffe [mailto:drew@lowerunit.com]
> Sent: Saturday, July 20, 2002 3:03 AM
> To: struts-user@jakarta.apache.org
> Subject: DispatchAction and declarative exception handling
>
>
> I'm not sure if this is intended behavior, but I've found what looks to
> me like a problem with the DispatchAction class. In the "dispatchMethod"
> method, exceptions are trapped and when they occur, are usually
> processed by a call to "response.sendError()". This appears to bypass
> any exception handling that might be configured declaratively. For
> instance, if I have a login method on a subclass of "DispatchAction",
> and it throws an "AuthenticationException", the dispathMethod will see
> that as an InvocationTargetException and make a call to
> "response.sendError()". So no matter how I've configured exceptions in
> struts-config, I'll always get an error.
>
> I would think that for at least "InvocationTargetException", this should
> not be the way the exception is handled. I've modified my subclass of
> DispatchAction to override "dispatchMethod". In my override, I treat
> "InvocationTargetException" differently than the other trapped
> exceptions. Because you'd usually reach this exception if there was an
> exception in the action method, it will usually be a business exception
> and not a system exception. My override pulls the cause exception out
> ("getCause") and throws it, rather than calling "response.sendError()"
> and returning null. As a result, I can throw business exceptions in my
> dispatchAction subclass methods and configure how they are handled in
> the struts-config file.
>
> Does this sound right, or am I missing something in how the
> DispatchAction is supposed to be used?
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>