Announcement Announcement Module
Collapse
No announcement yet.
Could not resolve view with name... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not resolve view with name...

    I'm new to Spring and am trying to get a prototype application up and running with Spring MVC. I got the first controller up fine, but when I added a second controller and view, I started getting an error that I can't resolve. It seems straightforward but I can't figure it out. I've Google'd and looked through the forums but can't find anything helpful. Here is the exception I'm getting...

    javax.servlet.ServletException: Could not resolve view with name 'request-requestForm' in servlet with name 'cms'
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:1088)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:841)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:755)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:396)
    at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:350)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:175)
    at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve .invoke(CachedConnectionValve.java:156)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Thread.java:595)


    The app is very simple at this point. Here are the contents of my views.properties file....

    request-index.class=org.springframework.web.servlet.view.J stlView
    request-index.url=/WEB-INF/views/request/index.jsp
    request-requestForm.class=org.springframework.web.servlet. view.JstlView
    request-requestForm.url=/WEB-INF/views/request/requestForm.jsp

    Here is the code in the controller that I know is being called because I print out a debug statement....

    public ModelAndView createRequest(HttpServletRequest request, HttpServletResponse response)throws Exception{
    System.out.println("test");
    return new ModelAndView("request-requestForm",new java.util.HashMap());
    }

    Any pointers to some documentation would be greatly appreciated..
    Thanks

  • #2
    It seems that you have defined a ResourceBundleViewResolver configuration. Can you post that? And if possible your controller definitions from the applicationContext xml as well.

    Comment


    • #3
      Here is my spring configuration and web.xml...

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
      <!-- - Application context definition for "springapp" DispatcherServlet. -->
      <beans>

      <bean id="publicUrlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
      <property name="mappings">
      <props>
      <prop key="/request.htm">requestController</prop>
      <prop key="/menu.htm">menuController</prop>
      </props>
      </property>

      </bean>

      <!-- Controller Definitions -->
      <bean id="requestController" class="com.am.changemgt.control.RequestController" >
      <property name="methodNameResolver">
      <ref local="requestMethodNameResolver"/>
      </property>
      </bean>
      <bean id="menuController" class="com.am.changemgt.control.MenuController">
      <property name="methodNameResolver">
      <ref local="requestMethodNameResolver"/>
      </property>
      </bean>

      <!-- Control resolvers -->
      <bean id="requestMethodNameResolver" class="org.springframework.web.servlet.mvc.multiac tion.ParameterMethodNameResolver">
      <property name="paramName">
      <value>method</value>
      </property>
      </bean>

      <!-- View resolvers -->
      <bean id="viewResolver" class="org.springframework.web.servlet.view.Resour ceBundleViewResolver">
      <property name="basename">
      <value>views</value>
      </property>
      </bean>
      </beans>




      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <display-name>CMS</display-name>

      <servlet>
      <servlet-name>cms</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>cms</servlet-name>
      <url-pattern>*.htm</url-pattern>
      </servlet-mapping>

      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      </web-app>

      Comment


      • #4
        You may have the following issues

        a) views may not exist in your classes path (WEB-INF/classes)
        b) The definition of the request-requestForm may not exist there or not be configured properly Look up this. http://www.springframework.org/docs/reference/view.html (Section 14.2.1).
        If possible display the property file details as well.

        Comment


        • #5
          Property values are in the original post.
          Thanks

          Comment


          • #6
            possible solution

            We had a similar problem -
            this was trying to access a URL for a REST service.
            It worked fine through the browser, but would bomb with commons HTTPClient

            method.addRequestHeader("Accept","*/*;");
            was the fix.

            not too sure where the problem ultimately lies. But, according to the spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)
            "If no Accept header field is present, then it is assumed that the client accepts all media types"

            Comment

            Working...
            X