I am trying to extend ExceptionMappingInterceptor. I created a listener which overrides ExceptionMappingInterceptor’s publishException(…) method. But it is not listening for any global exceptions which are not handled in the application.
Here are my configurations.
//Handler
public class GlobalExceptionHandler extends ExceptionMappingInterceptor
{
private Logger logger = AppLogger.getLogger(this.getClass());
@Override
protected void publishException(ActionInvocation invocation, ExceptionHolder exceptionHolder)
{
logger.error("Global Exception msg: "+ exceptionHolder.getException().getMessage(), exceptionHolder.getException());
super.publishException(invocation, exceptionHolder);
}
}
In struts.xml
<interceptors>
<interceptor name="sessionInterceptor" class="com.jak.session.SessionInterceptor" />
<interceptor name="exception" class="com.jak.exception.GlobalExceptionHandler" />
<interceptor-stack name="mymatrixxInterceptorStack">
<interceptor-ref name="exception"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="sessionInterceptor"/>
</interceptor-stack>
</interceptors>
<global-results>
<result name="exception" type="tiles">myAccount</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="exception" />
</global-exception-mappings>
<action name="myAccount">
<interceptor-ref name="mymatrixxInterceptorStack"></interceptor-ref>
<result type="tiles">errorPage</result>
</action>
While uploading a file I got an exception as ‘No result defined for action com.dsdar.business.offer.CampaignUpdateAction and result input‘. But this exception is not handled by this interceptor. I don’t the reason why it is not listening.
In struts.xml
I do not understand English. The reason is, please ask someone. (> _ <)