Announcement Announcement Module
Collapse
No announcement yet.
Spring & Tiles setup Not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring & Tiles setup Not working

    I am trying to configure Sring 3.0 and Tiles 2.1.2 to work properly. But am faced with the following error when I make a call to the tiles definition template -

    I have Tiles working on its own fine and Spring MVC working on its own fine, but cannot get both of them working together. This is the error I get -

    Code:
    2009-11-26 16:53:16,092 DEBUG [http-8080-1] org.springframework.web.servlet.DispatcherServlet (line 674): Could not complete request
    javax.servlet.ServletException: Could not resolve view with name 'WEB-INF/view/layouts/standard' in servlet with name 'mvc-servletConfig'
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1042)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
    	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:630)
    	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.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
    	at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
    	at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
    	at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103)
    	at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:659)
    	at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:678)
    	at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)
    	at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:322)
    	at org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:100)
    	at org.springframework.js.ajax.tiles2.AjaxTilesView.renderMergedOutputModel(AjaxTilesView.java:115)
    	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
    	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.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    	at java.lang.Thread.run(Thread.java:595)
    ...
    When I make the request to the definition - http://localhost:8080/app/template the above error occurs. It is as though something is trimming off the ".jsp" suffix of the template location "WEB-INF/view/layouts/standard".

    This is my Spring config file -

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:security="http://www.springframework.org/schema/security"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
    						http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    						http://www.springframework.org/schema/context
    						http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <context:annotation-config />
        <context:component-scan base-package="com.company.package.web" />
    
        <bean  id="annotationMapping"
            class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
            <property name="order" value="0"/>
    		<property name="interceptors" ref="webContentInterceptor"/>
        </bean>
    
    	<bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
    		<property name="cacheSeconds" value="0"/>
    	</bean>
    	
    	<bean id="controllerMappings" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
    		<property name="order" value="1" />
    		<property name="interceptors" ref="webContentInterceptor"/>
    	</bean>
    	
    	<bean id="viewFallbackMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="order" value="2"/>
    		<property name="defaultHandler">
    			<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" >
        		</bean>
    		</property>
    	</bean>
    
    	<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.js.ajax.tiles2.AjaxTilesView" />
    	</bean>
    	
    	<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/tiles.xml</value>
    			</list>
    		</property>
    	</bean>
    	
    	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    		<property name="basename" value="/WEB-INF/messages/global" />
    	</bean>
    </beans>
    And this is my Tiles.xml file -

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
           "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
    
    <tiles-definitions>
    	<definition name="template" template="/WEB-INF/layouts/standard.jsp" />
    </tiles-definitions>
    This is the relevant directory structure -

    Code:
    /webapp
     /WEB-INF
      /view
       ...
      /layouts
       standard.jsp
      tiles.xml
      mvc-servletConfig.xml
      ...
    Any help on this would be great appreciated. Am I doing something fundamentally wrong?

    wr1472

  • #2
    Not sure about the followings
    <bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedVie wResolver">
    <property name="viewClass" value="org.springframework.js.ajax.tiles2.AjaxTile sView" />
    </bean>

    Comment


    • #3
      care to elaborate?

      A bit more information would be helpful! I got that configuration off some springsource training material.

      Comment


      • #4
        Got a fix working

        An update for others who may face similar problems -

        I have got a setup working after great effort. The above configuration has not changed apart from this -

        Code:
        <!-- Resolves view names to Tiles 2 definitions -->
        	<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
        <!--		<property name="viewClass" value="org.springframework.js.ajax.tiles2.AjaxTilesView"/>-->
        		<property name="viewClass" value="com.company.patch.AjaxTiles212View"/>
        	</bean>
        This points to a custom AjaxTilesView resolver. the reason being that the error I was facing was to do with deprecated Tiles methods being called from the Spring AjaxTilesView class.

        I am using Spring 3.0 with Tiles 2.1.2 and Spring Webflow 2.0.8. Within the Tiles BasicTilesContainer class there is a deprecated method getContextFactory() that returns null that is called from Spring. The custom class calls the newer getRequestContextFactory() that works.

        There is a JIRA ticket here. This is where I also got the code from.

        A few things worry me -

        1. It is not clear what version of Tiles, Spring was written against, as I have tried Tiles 2.2.1 and could not get it to work because of other deprecated methods. I have also tried 2.1.0 and could not get that to work either because of yet another deprecated method call!

        2. Springsource need to provide some comprehensive documentation and working examples as I have spent a lot of time going over fundamental things like this. At the very least developers will know what versions are compatible.

        3. More a gripe with Tiles - but for a release that is up to version 2.x there is still a lot of big changes going in for minor and patch releases. Granted 2.x of any release isn't hugely mature and code always changes, but at least try and make it backward compatile between patches! If a method was marked as deprecated in 2.1.0 then do not simply return null in 2.1.2. For patched releases, sudden changes like this can be very frustrating, and make the entire framework appear less robust. It would have been better to simply call the new method in 2.1.2 with a warning log saying it is deprecated, and then at the next minor release to remove. Just returning null gives no useful feedback!

        Anyways, my solution (and minor rant over!). HTH others who face this problem.

        wr1472

        Comment

        Working...
        X