Struts2 Application hides my exceptions after adding Interceptor -


so have struts2 application i'm working on. on front page have section display exceptions application throws. worked until added custom interceptor.

here interceptor code:

public string intercept(actioninvocation actioninvocation) throws exception {      string result = actioninvocation.invoke();      return result; } 

this code in action class exception gets generated, occurs authservice.authorize() called:

if(authservice.authorize(username, password)) {         if(authservice.adminauthorized()) {             return "admin";         }         return success;     } 

this inside of authservice.authorize(), throws null point exception when acc accessed :

try {             acc = profilerepository.wheresingle("username", "=", username);         } catch (exception e) {             return false;         }          if (acc.password.equals(password)) { 

however, when page loaded. not populated:

<s:property value="%{exception.message}"/> 

i have tested , work if throwing exception action class. not calling redirectaction or anything

here top of default package definition other packages extend

<package name="default" namespace="/" extends="struts-default">      <!-- interceptors -->     <interceptors>         <interceptor name="conversation" class="global.conversationinterceptor"/>         <interceptor-stack name="dils-stack">             <interceptor-ref name="defaultstack"/>             <interceptor-ref name="conversation"/>                         </interceptor-stack>     </interceptors>      <default-interceptor-ref name="dils-stack"/>      <global-results>         <result name="exception" >/index.jsp</result>     </global-results>      <global-exception-mappings>         <exception-mapping exception="java.lang.exception" result="exception"/>         <exception-mapping exception="java.lang.nullpointerexception" result="exception"/>     </global-exception-mappings> 

how interceptor stack defined action? exceptionmappinginterceptor should defined first in stack. can post interceptor stack configuration struts.xml? custom interceptor should not interfering (it nothing).

updated:

i able reproduce issue, occurs me or without custom interceptor.

the reason looking exception message, not set nullpointerexceptions automatically thrown (as in case). can confirm instead displaying stack trace, such as: %{exceptionstack}

%{exception.message} null nullpointerexception, , displays nothing. if instead throw exception message (e.g., throw new runtimeexception("omg!");), see message.

also, note must specify more specific exception mappings before less specific mappings in struts.xml. because nullpointerexception more specific exception, must list first. note doesn't matter in example, because map same thing. know npe map first entry, not second.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -