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]

Reply via email to