struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Kiley <jhki...@summa-tech.com>
Subject Re: Exceptions thrown by constructor different from those thown by execute() ?
Date Tue, 23 Jun 2009 12:50:37 GMT
Presumably the code calling execute() wraps it in a try/catch, but the call
that is instantiating the action in the first place doesn't do that.  You'd
have to look at the source to be sure, but of course that's the nice part
about working on open-source projects.
>From a philosophical perspective, though -- no clue, I don't have a lot of
insight into why the devs make all the decisions they make.

jk

On Tue, Jun 23, 2009 at 5:12 AM, Jan T. Kim <j.kim@uea.ac.uk> wrote:

> On Tue, Jun 23, 2009 at 06:41:48AM -0200, Pawe? Wielgus wrote:
> > Hi Jan,
> > i'm not going into details of your solution but interceptors are a way
> > better tool for that job, search the list for authentication subjects.
> > You can also use libraries like acegi or similiar.
>
> thanks for this pointer, I agree that this is probably a bad example
> as such ad-hoc development of authentication mechanisms isn't really
> a good idea.
>
> My question is about exception handling in general, though: Why does
> my handler work as expected when the exception is thrown by execute(),
> but not when it's thrown by the constructor?
>
> Having run into this, I'd like to understand it before moving on.
>
> Best regards, Jan
>
> > 2009/6/22, Jan T. Kim <j.kim@uea.ac.uk>:
> > > Dear All,
> > >
> > > I'm trying to use exceptions to make sure a user is logged in, using
> > > struts 2.1.6. My idea is
> > >
> > >     * a subclass of ActionSupport that checks that a user is logged
> > >       in, and throws a NotLoggedInException if that's not the case
> > >
> > >     * all other action handlers are subclasses of that subclass
> > >
> > >     * use a global exception mapping to map the NotLoggedInException
> > >       to a suitable login action
> > >
> > > I can't seem to get this to work, I get a 500 response with a stack
> > > trace, saying "Unable to instantiate Action". If I arrange for the
> > > constructor to complete without an exception and for the execute()
> > > method to throw a NotLoggedInException, I get to the login action as
> > > I intend.
> > >
> > > So it seems that only exceptions thrown by execute(), but not those
> > > thrown by constructors, are handled as specified by the exception
> > > mappings (at least the global ones) -- is that right? And if so, why
> > > is that?
> > >
> > > Or do you thing I've just made some silly mistake here?
> > >
> > > Best regards, Jan
> > > --
> > >  +- Jan T. Kim -------------------------------------------------------+
> > >  |             email: j.kim@uea.ac.uk
> |
> > >  |             WWW:   http://www.cmp.uea.ac.uk/people/jtk
> |
> > >  *-----=<  hierarchical systems are for files, not for humans  >=-----*
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
> --
>  +- Jan T. Kim -------------------------------------------------------+
>  |             email: j.kim@uea.ac.uk                                 |
>  |             WWW:   http://www.cmp.uea.ac.uk/people/jtk             |
>  *-----=<  hierarchical systems are for files, not for humans  >=-----*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message