title: JstlView adds path prefix recursively causing StackOverflowError
body: <p>all,</p>
  
  <p>I am writing a demo application to learn usage of the </p>
  
  <pre><code>org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping
  </code></pre>
  
  <p>class. When I run the application; I get a stack over flow error and logs show that /WEB-INF/view/ is getting recursively prefixed to the URL path. Please help in solving this.</p>
  
  <p>Here's the servlet-context.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
    &lt;!-- DispatcherServlet Context: defines this servlet's request-processing 
      infrastructure --&gt;
  
    &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
    &lt;annotation-driven /&gt;
  
    &lt;beans:bean id="projectDao" class="chomu.dao.ProjectDaoImpl" /&gt;
    &lt;beans:bean id="projectService" class="chomu.service.ProjectPersistenceService" /&gt;
  
    &lt;!-- Bind to a naming convention for controllers and views --&gt;
    &lt;!-- p:interceptors-ref="localeChangeInterceptor" --&gt;
    &lt;beans:bean id="classnameControllerMappings"
      class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"
      p:order="1" p:caseSensitive="true"&gt;
      &lt;beans:property name="defaultHandler"&gt;
        &lt;beans:bean
          class="org.springframework.web.servlet.mvc.UrlFilenameViewController" /&gt;
      &lt;/beans:property&gt;
    &lt;/beans:bean&gt;
  
    &lt;!-- Enables annotated POJO @Controllers --&gt;
    &lt;beans:bean
      class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt;
  
    &lt;!-- Enables plain Controllers --&gt;
    &lt;beans:bean
      class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /&gt;
  
    &lt;!-- Resolves views selected for rendering by @Controllers to .jsp resources 
      in the /WEB-INF/views directory --&gt;
    &lt;beans:bean
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;beans:property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
      &lt;beans:property name="suffix" value=".jsp" /&gt;
    &lt;/beans:bean&gt;
  
    &lt;!-- Imports user-defined @Controller beans that process client requests --&gt;
    &lt;beans:import resource="controllers.xml" /&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>the controllers.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;
  
    &lt;!-- Scans within the base package of the application for @Components to 
      configure as beans --&gt;
    &lt;context:component-scan base-package="chomu" /&gt;
  
    &lt;tx:annotation-driven proxy-target-class="true" /&gt;
    &lt;mvc:annotation-driven /&gt;
  
    &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
    &lt;bean id="validator"
      class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>the Controller code</p>
  
  <pre><code>package chomu.controller;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  import chomu.domain.Project;
  import chomu.service.ProjectPersistenceService;
  
  /**
   * @author amisr1
   * @dateCreated Aug 18, 2011
   * @version $Revsion:$
   * 
   *          $LastChangedBy:$
   * @since
   */
  @Controller
  public class ProjectController {
  
    @Autowired
    private ProjectPersistenceService projectService;
  
    /**
     * @return the projectService
     */
    public ProjectPersistenceService getProjectService() {
      return projectService;
    }
  
    /**
     * @param projectService
     *          the projectService to set
     */
    public void setProjectService(ProjectPersistenceService projectService) {
      this.projectService = projectService;
    }
  
    @RequestMapping(method=RequestMethod.GET)
    public List&lt;Project&gt; list(){
      List&lt;Project&gt; projectList = new ArrayList&lt;Project&gt;();
      projectList.add(projectService.getProject(2L));
      projectList.add(projectService.getProject(3L));
      return projectList;
    }
  
  }
  </code></pre>
  
  <p>and the jsp</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
  &lt;jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
      xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0"&gt;
      &lt;jsp:directive.page contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1" session="false" /&gt;
      &lt;jsp:output doctype-root-element="html"
          doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
          doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
          omit-xml-declaration="true" /&gt;
      &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;table&gt;
          &lt;c:forEach var="project" items="${projectList}"&gt;
              &lt;tr&gt;
                  &lt;td&gt;${project.id}&lt;/td&gt;
                  &lt;td&gt;${project.name}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/c:forEach&gt;
      &lt;/table&gt;
  &lt;/body&gt;
      &lt;/html&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>I get message similar to the one below in logs before my eclipse crashes:</p>
  
  <pre><code>DEBUG: org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/'
  DEBUG: org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/WEB-INF/views/'
  DEBUG: org.springframework.web.servlet.view.JstlView - Forwarding to resource [/WEB-INF/views/WEB-INF/views/WEB-INF/views/project/list'
  Aug 22, 2011 8:02:35 PM org.apache.catalina.core.ApplicationDispatcher invoke
  SEVERE: Servlet.service() for servlet appServlet threw exception
  java.lang.StackOverflowError
      at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:505)
      at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
      at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:547)
      at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
      at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:547)
  </code></pre>
  
  <p>and further down the logs </p>
  
  <pre><code>at org.springframework.web.context.request.ServletRequestAttributes.updateAccessedSessionAttributes(ServletRequestAttributes.java:222)
      at org.springframework.web.context.request.AbstractRequestAttributes.requestCompleted(AbstractRequestAttributes.java:48)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:664)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>Seeing InternalResourceView in the stack trace when I am actually using UrlBasedViewResolver puzzles me even more.
  The WEB-INF/views is actually prefixed some 50 odd times before throwing the error I have pasted a smaller representation of it to avoid verbosity.</p>
  
  <p>Not sure what causing this effect.</p>