Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC + Tiles : HTTP 404 Error (resource not found) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC + Tiles : HTTP 404 Error (resource not found)

    Hi, Ive been tinkering Spring MVC for a while now and Im currently introducing Tiles into it. However I got stucked with this problem for quite awhile now and I hope good souls out here can finally pull me out on this issue.

    first, the configuration: context-servlet.xml
    Code:
    	<context:annotation-config />
    
    	<context:component-scan base-package="com.ifvi.rims.controllers">
            <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        </context:component-scan>
    	 
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
    
    	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    
    	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" >
    		<property name="defaultHandler">
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
    		</property>
    	</bean>
    			 
    	<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" >
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/tiles-defs/definitions.xml</value>
    			</list>
    		</property>
    	</bean>
    
    	<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">		
    		<property name="order" value="0" />
    		<property name="requestContextAttribute" value="requestContext" />
    		<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
    		<property name="viewNames" value="*.tvw" />
    	</bean>	
    
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="order" value="1" />
    		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    		<property name="prefix" value="/WEB-INF/jsp/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    and the tiles' definitions.xml
    Code:
    <tiles-definitions>
      <definition name="baseLayout.tvw" template="/WEB-INF/jsp/baseLayout.jsp">
          <put-attribute name="title"  value="Template"/>
          <put-attribute name="dojoIncludes" value="/WEB-INF/tiles/dojoIncludes.jsp" />
          <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
          <put-attribute name="menu"   value="/WEB-INF/tiles/left.jsp"/>
          <put-attribute name="content"   value="/WEB-INF/tiles/body.jsp"/>
          <put-attribute name="footer"   value="/WEB-INF/tiles/footer.jsp"/>
      </definition>
      
      <definition name="saleEntry.tvw" extends="baseLayout.tvw" template="/WEB-INF/jsp/saleEntry.jsp">
          <put-attribute name="title"  value="Sale Entry"/>
          <put-attribute name="menuId" value="sale" />
          <put-attribute name="content"   value="/WEB-INF/tiles/content_saleEntry.jsp"/>      
      </definition>
      
      <definition name="customer.tvw" extends="baseLayout.tvw" template="/WEB-INF/jsp/customerManager.jsp">
          <put-attribute name="title"  value="Creditor Manager"/>
          <put-attribute name="menuId" value="customer" />
          <put-attribute name="content"   value="/WEB-INF/tiles/customerMgr.jsp"/>      
      </definition>
      
      <definition name="inventory.tvw" extends="baseLayout.tvw" template="/WEB-INF/jsp/inventoryManager.jsp">
          <put-attribute name="title"  value="Inventory Manager"/>
          <put-attribute name="menuId" value="inventory" />
          <put-attribute name="content"   value="/WEB-INF/tiles/inventoryMgr.jsp"/>      
      </definition>
    </tiles-definitions>
    I checked the location of the jsp files many times and they're all in the right position as specified in the tile definition.

    the controller: - PageController.java
    Code:
    @Controller
    public class PageController {	
    	@Autowired
    	private CustomerService cservice;
    	
    	@RequestMapping("/page/salesEntry.html")
    	public String saleEntryHandler(){		
    		System.out.println("SaleEntry");
    		return "saleEntry.tvw";
    	}
    	
    	@RequestMapping("/page/inventory.html")
    	public void inventoryHandler(){
    		System.out.println("Inventory");
                    return "inventory.tvw";
    	}
    }
    Given the above code snippets, running the webapp in tomcat6.0.20 returns an error in the browser:

    I try to access: http://localhost:8080/RIMSWeb/page/salesEntry.html.
    The string - SaleEntry - is properly printed in the console but the browser
    showed this error.

    Code:
    HTTP Status 404 - /RIMSWeb/WEB-INF/jsp/saleEntry.jsp
    
    -------------------------------------------------------------------
    
    type Status report
    
    message /RIMSWeb/WEB-INF/jsp/saleEntry.jsp
    
    description The requested resource (/RIMSWeb/WEB-INF/jsp/saleEntry.jsp) is not available.
    and the trace debug lines isnt not helping much:

    Code:
       -- other Digester.java debug lines in here --
    
    13:23:17 DEBUG [http-8080-1] (UrlDefinitionsFactory.java:253) - File jndi:/localhost/RIMSWeb/WEB-INF/tiles-defs/definitions_en.xml not found, continue
    13:23:17 DEBUG [http-8080-1] (UrlDefinitionsFactory.java:253) - File jndi:/localhost/RIMSWeb/WEB-INF/tiles-defs/definitions_en_PH.xml not found, continue
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='saleEntry.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='inventory.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='customer.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='saleEntry.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='inventory.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (DefinitionsImpl.java:223) - Resolve definition for child name='customer.tvw' extends='baseLayout.tvw'.
    13:23:17 DEBUG [http-8080-1] (BasicTilesContainer.java:603) - Dispatching to definition path '/WEB-INF/jsp/saleEntry.jsp '
    13:23:17 DEBUG [http-8080-1] (FrameworkServlet.java:591) - Successfully completed request
    Please help! been figuring this out for a week! Thanks in advance.

  • #2
    I suggest the forum search as this question has been answered numerous times.

    Short version you can only use 1 UrlBasedViewResolver and you have 2 (InternalResourceViewResolver is an extension of the UrlBasedViewResolver).

    Comment

    Working...
    X