Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6372091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:11:18+00:00 2026-05-25T01:11:18+00:00

all, I am writing a demo application to learn usage of the org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping class.

  • 0

all,

I am writing a demo application to learn usage of the

org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping

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.

Here’s the servlet-context.xml

    <?xml version="1.0" encoding="UTF-8"?>
<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">

  <!-- DispatcherServlet Context: defines this servlet's request-processing 
    infrastructure -->

  <!-- Enables the Spring MVC @Controller programming model -->
  <annotation-driven />

  <beans:bean id="projectDao" class="chomu.dao.ProjectDaoImpl" />
  <beans:bean id="projectService" class="chomu.service.ProjectPersistenceService" />

  <!-- Bind to a naming convention for controllers and views -->
  <!-- p:interceptors-ref="localeChangeInterceptor" -->
  <beans:bean id="classnameControllerMappings"
    class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"
    p:order="1" p:caseSensitive="true">
    <beans:property name="defaultHandler">
      <beans:bean
        class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    </beans:property>
  </beans:bean>

  <!-- Enables annotated POJO @Controllers -->
  <beans:bean
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

  <!-- Enables plain Controllers -->
  <beans:bean
    class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />

  <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory -->
  <beans:bean
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <beans:property name="viewClass"
      value="org.springframework.web.servlet.view.JstlView" />
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
  </beans:bean>

  <!-- Imports user-defined @Controller beans that process client requests -->
  <beans:import resource="controllers.xml" />

</beans:beans>

the controllers.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <!-- Scans within the base package of the application for @Components to 
    configure as beans -->
  <context:component-scan base-package="chomu" />

  <tx:annotation-driven proxy-target-class="true" />
  <mvc:annotation-driven />

  <mvc:resources mapping="/resources/**" location="/resources/" />

  <bean id="validator"
    class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</beans>

the Controller 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<Project> list(){
    List<Project> projectList = new ArrayList<Project>();
    projectList.add(projectService.getProject(2L));
    projectList.add(projectService.getProject(3L));
    return projectList;
  }

}

and the jsp

<?xml version="1.0" encoding="ISO-8859-1" ?>
<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">
    <jsp:directive.page contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1" session="false" />
    <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" />
    <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Insert title here</title>
</head>
<body>
    <table>
        <c:forEach var="project" items="${projectList}">
            <tr>
                <td>${project.id}</td>
                <td>${project.name}</td>
            </tr>
        </c:forEach>
    </table>
</body>
    </html>
</jsp:root>

I get message similar to the one below in logs before my eclipse crashes:

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)

and further down the logs

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)

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.

Not sure what causing this effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:11:19+00:00Added an answer on May 25, 2026 at 1:11 am

    Got it to work with some help from the spring forum guys, I made the following changes:

    • Removed the annotation-driven ad mvc:annotation-driven tags from the servlet-context and controllers XML respectively.

    the servlet-context.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
    
      <!-- DispatcherServlet Context: defines this servlet's request-processing 
        infrastructure -->
    
      <beans:bean id="projectDao" class="chomu.dao.ProjectDaoImpl" />
      <beans:bean id="projectService" class="chomu.service.ProjectPersistenceService" />
    
      <!-- Bind to a naming convention for controllers and views -->
      <!-- p:interceptors-ref="localeChangeInterceptor" -->
      <beans:bean id="classnameControllerMappings"
        class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"
        p:order="1" p:caseSensitive="true">
      <beans:property name="defaultHandler">
        <beans:bean
          class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
      </beans:property>
      </beans:bean>
    
      <!-- Enables annotated POJO @Controllers -->
      <beans:bean
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
    
      <!-- Enables plain Controllers -->
      <beans:bean
        class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    
      <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
      <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView" />
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
      </beans:bean>
    
      <!-- Imports user-defined @Controller beans that process client requests -->
      <beans:import resource="controllers.xml" />
    
    </beans:beans>
    

    the controllers.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
    
      <!-- Scans within the base package of the application for @Components to 
        configure as beans -->
      <context:component-scan base-package="chomu" />
    
      <mvc:resources mapping="/resources/**" location="/resources/" />
    
      <bean id="validator"
        class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
    </beans>
    

    but the root cause was a fault in the servlet mapping, so changed the Dispatechr Servlet mapping to following in web.xml

        <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/app/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    Changed /* to / which was causing the recursive addition of view since it could not find the correct one.

    The spring Forum thread is here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a class to handle all database-activity in my application, and so
I am writing an application where all the request to the internet should go
I am writing a quick and dirty application that reads all the files from
I'm writing some code for a class constructor which loops through all the properties
I'm writing a query for an application that needs to list all the products
I am writing an application that downloads large files in the background. All clients
I'm writing a web application that allow user upload their files on the app.
I'm writing a small demo application in Java using Spring, that needs to have
If one application is writing all its activity data in one log file, is
I'm writing an application that requires all users to access data on a central

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.