Announcement Announcement Module
Collapse
No announcement yet.
HandlerExceptionResolver strange behavior Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HandlerExceptionResolver strange behavior

    I have setup a small application using spring 2.5.5. on the s2ap platform (rc1)

    Controller:

    _At_RequestMapping("/poc.go")
    _At_Controller
    public class MyController extends AbstractController implements
    HandlerExceptionResolver {
    ...

    public ModelAndView resolveException(HttpServletRequest request,
    HttpServletResponse response, Object arg2, Exception exceptoin) {

    ModelAndView mav = new ModelAndView(new ErrorView());


    return mav;
    }


    The error view looks like:

    public class ErrorView implements View {

    public String getContentType() {
    return "application/json";
    }

    public void render(Map arg0, HttpServletRequest request,
    HttpServletResponse response) throws Exception {

    PrintWriter writer = response.getWriter();
    writer.write("error-view");

    }
    }

    In case of an error in the controller , the ErrorView should simply output "error-view", thats all...

    Running the code in this way, the caught exception is directly passed into the frontend and displayed as a "SpringSource Application Platform - Error report".

    The expected behavior from my point of view however would be however that "error-view" would simply be displayed on my browser.

    If I replace the
    ModelAndView mav = new ModelAndView(new ErrorView());
    by
    ModelAndView mav = new ModelAndView("errorView");
    and create the appropriate /views/errorView.ftl, no error report is generated and passed back to the browser screen.

    Strange for me as well is that when using a custom view as the one descripted before in a normal flow,
    no problem occurs.

    The type of view-resolver does not make the difference as well. Same things happen for the xml-resolver as well as for the freemarker-view-resolver



    Any idea what causes the error report to appear in the first sample ???
    Last edited by tmaus; Sep 1st, 2008, 11:02 AM.

  • #2
    Please use [ code][/code ] tags when posting code...

    First off all I would say argh at your code.

    1. You are mixing Spring 2.0 controllers and Spring 2.5 @Controller types
    2. HandlerExceptionResolver should be a separate class NOT a Controller

    Regarding your issue there is a known issue with Spring 2.5.5 (try 2.5.4 or the nightly build) om tomcat regarding exceptions.

    I expect it to fail with a JSP (errorView.jsp) as well. This is the combination of tomcat spring which should have been fixed by Juergen by now. So check out either an older version or the newer version.

    Comment


    • #3
      thanks ..
      that really helps me ..

      Comment

      Working...
      X