Hi,

Try to call super.init(configuration) here:
public void init(Configuration configuration) throws Exception { 
super.init(configuration); }

Christian

De : Venkat Ravuri [mailto:[email protected]]
Envoyé : February-11-13 6:41 PM
À : [email protected]
Objet : [Stripes-users] Exception handler not working

I followed the instructions about exception handler in 
http://www.stripesframework.org/display/stripes/Exception+Handling.

My exception handler doesn't kick in when my action bean method throws 
exception.
It shows ugly tomcat stack trace instead, why is not finding my exception 
handler. I tried to set in init Exception.Class , as well
as in extension.packages . Neither worked for me.  Please help

Can some one help, this is driving me crazy. Why is this not working as 
documented in 1.5 ?.



 public Resolution confirm() throws PortalException{
                        check();
                        return new RedirectResolution("/results.jsp");
 }


private void check() throws PortalException{
                        throw new PortalException("Login Processing failed");
}


My Web.xml


 <filter>
        <description>
            Provides essential configuration and request processing services
            for the Stripes framework.
        </description>
        <display-name>Stripes Filter</display-name>
        <filter-name>StripesFilter</filter-name>
        
<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>


        <!-- REQUIRED init parameter for the Stripes Filter. -->
        <init-param>
            <param-name>ActionResolver.Packages</param-name>
            <param-value>com.my.Registration,/WEB-INF/classes</param-value>
        </init-param>
        <init-param>
            <param-name>Extension.Packages</param-name>
            <param-value>com.my.Registration.ext</param-value>
        </init-param>
        <init-param>
                                    
<param-name>ExceptionHandler.Class</param-name>
                                    
<param-value>com.my.Registration.excep.CustomExceptionHandler</param-value>
                        </init-param>

    </filter>
 <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

    <filter-mapping>
        <filter-name>StripesFilter</filter-name>
        <servlet-name>StripesDispatcher</servlet-name>
        <dispatcher>REQUEST</dispatcher>

    </filter-mapping>

       <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
-->
    <!--         Configuration of the Stripes dispatcher Servlet.            -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <servlet>
        <servlet-name>StripesDispatcher</servlet-name>
        
<servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
    </servlet>


    <servlet-mapping>
        <servlet-name>StripesDispatcher</servlet-name>
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>


</web-app>



Here is my exception handler code below.

package com.my.excep;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import net.sourceforge.stripes.config.Configuration;
import net.sourceforge.stripes.exception.DefaultExceptionHandler;
import net.sourceforge.stripes.exception.StripesServletException;


public class CustomExceptionHandler extends  DefaultExceptionHandler {

            public static final String ERROR_JSP ="/Error.jsp";
            /** Doesn't have to do anything... */
    public void init(Configuration configuration) throws Exception { }

    public void handle(PortalException portalException,
            HttpServletRequest request,
            HttpServletResponse response) throws ServletException, 
StripesServletException, IOException {


            request.setAttribute("exception", portalException.getMessage());
            //                      new 
RedirectResolution(ERROR_JSP).execute(request, response);
            request.getRequestDispatcher(ERROR_JSP).forward(request, response);
    }


    public void catchAll(Throwable throwable,
                       HttpServletRequest request,
                       HttpServletResponse response) throws ServletException, 
StripesServletException, IOException {

        Exception ex = (Exception)throwable;
            if (ex instanceof PortalException) {
            PortalException pe = (PortalException) throwable;
            request.setAttribute("exception", pe.getMessage());
            //new RedirectResolution(ERROR_JSP).execute(request, response);
            request.getRequestDispatcher(ERROR_JSP).forward(request, response);
        }
            else {

                        request.setAttribute("exception", throwable);
                        
request.getRequestDispatcher(ERROR_JSP).forward(request, response);

            }
    }



}

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to