I think in this situation I would have SomeAction implement Preparable, and
put someComponent's initialization into the prepare() method, if I could get
away with it.  I realize that might not be possible in your situation, but
not knowing more details it's my first suggestion.

jk

On Wed, Jul 9, 2008 at 12:00 PM, Lyallex <[EMAIL PROTECTED]> wrote:

> Hi
>
> I have a question about handling Exceptions in Action constructors
>
> I have the following constructor in an Action
>
>        public SomeAction() throws BusinessComponentException {
>            someComponent = new SomeBusinessComponent();
>        }
>
> Now when an instance of this Action is instantiated it may be the case
> that the SomeBusinessComponent
> constructor may throw a BusinessComponentException, the question is
> how to handle this.
>
> As an aside It's also the case that the methods of this action may
> also throw such an Exception
> but I can manage that fine.
>
> The exception trace reveals the following
>
> Unable to instantiate Action, ...
>
>  
> com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:294)
>
> I tried to handle this by putting the following in struts.xml
>
> <global-results>
>   <result name="error">/friendlyError.jsp</result>
> </global-results>
>
> <global-exception-mappings>
>   <exception-mapping exception="java.lang.Exception" result="error"/>
> </global-exception-mappings>
>
> But no joy. I think this is because of the way the Exception
> interceptor does it's thing.
>
> Here's what my book (Struts2 in Action) says
>
> ...When the exception interceptor executes during its postprocessing
> phase ... Hmm, that would explain it, there is no post processing
> phase because execution doesn't get that far. (I think).
>
> Does anyone have a pattern for handling exceptions in Action constructors ?
>
> many TsIA
>
> lyallex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

Reply via email to