1
votes

I have developed my application locally in Tomcat 6.0 Server and whenever I get an exception, It’s successfully calling error page (jsp) and showing the exception. But the issue I’m facing is, when the same application is deployed in web logic server and whenever the user get an exception(run time exception), it’s not getting redirected to error page But rather I’m getting 404 error Frame work – Spring MVC Error page location - /WEB-INF/jsp/error.jsp

Any help will be appreciated .PFB my web.xml snippet

    <error-page>
     <exception-type>java.lang.Throwable</exception-type>
     <location>/WEB-INF/jsp/error.jsp</location>
    </error-page>

     <error-page>
      <exception-type>java.lang.RuntimeException</exception-type>
      <location>/WEB-INF/jsp/error.jsp</location>
    </error-page>
1
It sounds like it can't find the JSP. Are you sure it's included in the classpath for your deployment? - CodeChimp
yes sounds like in weblogic it can't able to locate the error jsp.Now I'm trying to impliment this using SimpleMappingExceptionResolver (rather than depending on servlet Container).Will let you know the outcome - Thomas

1 Answers

-1
votes

I have got the solution by moving the entire logic from servlet container to Spring container.

You need to configure CustomSimpleMappingExceptionResolver in springservlet.xml. The configuration should be done as given below

<bean
    class="com.****.CustomSimpleMappingExceptionResolver"
        p:warnLogCategory="org.springframework.web.servlet.DispatcherServlet">
        <property name="defaultErrorView" value="error" />
        <property name="exceptionMappings">
        <props>
            <prop key=".MissingServletRequestParameterException">error</prop>
            </props>
    </property>
</bean>

then

  1. define the error.jsp
  2. create your custom exception class and configure the same in SimpleMappingExceptionResolver config Class.
  3. Overide doResolveException in SimpleMappingExceptionResolver

    @Override protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {

    -------------------some code----------    
    

    return "";

    }