The default ExceptionMappingInterceptor is "closer" to the error (as it is configured by default), so it will intercept it first (on the way out... [1]). If you already have configured exception mappings for that interceptor, it will never reach your interceptor. It might be better for you to replace the the interceptor in the stack, as you have already tried. You can set up your own default stack in your application struts.xml file. It's a bit of duplication, but there's no need to edit the framework supplied configuration files.
[1] - http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-OrderofInterceptorExecution Nils-H On Wed, Apr 16, 2008 at 9:46 PM, Parker Grimes <[EMAIL PROTECTED]> wrote: > My interceptor is being called, but it appears that > com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor is still > being called before my interceptor, despite having my interceptor declared > first in the stack. As you can tell my interceptor is handed the "error" > result rather than catching the exception. > > The only way I was able to get it to work is by changing the 'exception' > interceptor definition in struts-default.xml to point to my class. As a side > note, is there a way to override struts-default.xml? I tried setting the > property > struts.configuration.files=my-struts-default.xml,struts-plugin.xml,struts.xml > and overriding the 'exception' interceptor in my-struts-default.xml, but the > struts-default.xml was still being loaded. So I ended up checking out the > struts2 source, editing struts-default.xml and packaging it myself, which is > kind of a pain. > > I have have tried both Struts 2.0.11 and 2.1.1 <http://2.1.1./>, also tried > it as a regular app and a portlet app and I get the same behavior. > > Thanks, > Parker > > On Wed, Apr 16, 2008 at 11:12 AM, Nils-Helge Garli Hegvik <[EMAIL PROTECTED]> > wrote: > > > > > I did some testing locally, and it looks to me like exceptions should > > be propagated properly. Are you sure that the exception is not handled > > somewhere else? From your logs, it appears that "error" is returned > > somewhere along the chain. > > > > Nils-H > > > > On Wed, Apr 16, 2008 at 12:46 AM, Parker Grimes <[EMAIL PROTECTED]> wrote: > > > I am trying to implement a custom exception mapping interceptor to be > > used > > > in my struts2 portlet. I implemented my own ExceptionMappingInterceptor > > > class that is similar to > > > com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor, the > > only > > > difference is that I send an email with the exception report to the > > > application administrators. I have used this same interceptor > > successfully > > > in a regular struts2 application. > > > > > > The problem I am having is that it appears that the action is being > > called > > > and the exception caught by some other class before it gets to my > > > interceptor even though my interceptor is declared first in my stack. > > Since > > > my custom interceptor is first in my stack shouldn't it be the first > > thing > > > to catch an exception begin thrown from my action? > > > > > > *My interceptor looks like this in struts.xml:* > > > <interceptors> > > > <interceptor name="customException" > > > class="edu.suu.struts2.interceptor.ExceptionMappingInterceptor"/> > > > <interceptor-stack name="myStack"> > > > <interceptor-ref name="customException"/> > > > <interceptor-ref name="portletDefaultStack"/> > > > </interceptor-stack> > > > </interceptors> > > > <default-interceptor-ref name="myStack"/> > > > > > > * > > > Here is my debug logging:* > > > DEBUG [com.opensymphony.xwork2.DefaultActionInvocation] - Executing > > action > > > method = optIn > > > DEBUG [edu.suu.googleapps.portlet.OptInAction] - optIn() > > > ---exception is thrown here--- > > > DEBUG [org.apache.struts2.portlet.result.PortletResult] - Executing > > result > > > in Event phase > > > DEBUG [org.apache.struts2.portlet.result.PortletResult] - Setting event > > > render parameter: /WEB-INF/jsp/error.jsp > > > DEBUG [edu.suu.struts2.interceptor.ExceptionMappingInterceptor] - > > result = > > > error > > > DEBUG [edu.suu.struts2.interceptor.ExceptionMappingInterceptor] - No > > > exceptions caught > > > DEBUG [org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher] - > > Leaving > > > processAction > > > DEBUG [org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher] - > > Entering > > > render > > > DEBUG [org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher] - > > > serviceAction > > > DEBUG [org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher] - > > Creating > > > action proxy for name = renderDirect, namespace = > > > DEBUG [com.opensymphony.xwork2.DefaultActionProxy] - Creating an > > > DefaultActionProxy for namespace and action name renderDirect > > > DEBUG [org.apache.struts2.portlet.interceptor.PortletStateInterceptor] > > - > > > Restoring value stack from event phase > > > DEBUG [org.apache.struts2.portlet.interceptor.PortletStateInterceptor] > > - > > > Restored stack > > > DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] - intercept > > > '/renderDirect' { > > > DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] - > > > requested_locale=null > > > * > > > The interceptor looks like this:* > > > public String intercept(ActionInvocation invocation) throws Exception { > > > HttpServletRequest request = ServletActionContext.getRequest(); > > > String result = null; > > > try { > > > logger.debug("Invoking action, looking for exceptions."); > > > result = invocation.invoke(); > > > logger.debug("result = " + result); > > > logger.debug("No exceptions caught"); > > > } catch (Exception ex) { > > > logger.debug("Exceptions caught"); > > > ex.printStackTrace(); > > > ...... > > > } > > > return result; > > > } > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]