title: Spring mvc 3 with tiles 2 gives 400 bad request
body: <p>I'm trying to add Apache Tiles to a simple Spring MVC webapp I'm playing with and I can't seem to get it to work (it worked without Tiles). Any request I make gives back 400 bad request, nothing appears in the log (even set to DEBUG) so I'm not sure where to start debbuging. As far as I can tell the Controller mapped method is never called as there's logging in there and it doesn't appear in the log (plus before that I would get a lot of debug info from spring about resolving the mapping to the controller before it was actually called - which now doesn't appear).</p>
  
  <p>My config files are as follows (all under /WEB-INF/):
  web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      &lt;display-name&gt;myapp&lt;/display-name&gt;    
  
      &lt;!-- Enable escaping of form submission contents --&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;defaultHtmlEscape&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/context-param&gt;        
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath*:META-INF/spring/applicationContext*.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;filter&gt;
          &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;encoding&lt;/param-name&gt;
              &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/filter&gt;
      &lt;filter&gt;
          &lt;filter-name&gt;HttpMethodFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.HiddenHttpMethodFilter&lt;/filter-class&gt;
      &lt;/filter&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;HttpMethodFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;!-- Handles Spring requests --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;session-config&gt;
          &lt;session-timeout&gt;10&lt;/session-timeout&gt;
      &lt;/session-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>myapp-servlet.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd                 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd                 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"&gt;
  
      &lt;!-- The controllers are autodetected POJOs labeled with the @Controller 
          annotation. --&gt;
      &lt;context:component-scan base-package="com.myapp.controller"
          use-default-filters="false"&gt;
          &lt;context:include-filter expression="org.springframework.stereotype.Controller"
              type="annotation" /&gt;
      &lt;/context:component-scan&gt;
  
      &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving 
          up static resources --&gt;
      &lt;mvc:resources location="/resources/" mapping="/resources/**" /&gt;
  
      &lt;!-- Allows for mapping the DispatcherServlet to "/" by forwarding static 
          resource requests to the container's default Servlet --&gt;
      &lt;mvc:default-servlet-handler /&gt;
  
      &lt;mvc:annotation-driven /&gt;
  
      &lt;bean id="tilesConfigurer"
          class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
          &lt;property name="definitions"&gt;
              &lt;list&gt;
                  &lt;value&gt;/WEB-INF/tiles.xml&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;    
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="viewClass"
              value="org.springframework.web.servlet.view.tiles2.TilesView" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>tiles.xml</p>
  
  <pre><code>&lt;tiles-definitions&gt;    
      &lt;definition name="product_detail" template="/WEB-INF/layout/detail.jsp"&gt;
          &lt;put-attribute name="header" value="/WEB-INF/view/header.jsp" /&gt;
          &lt;put-attribute name="banner" value="" /&gt;
          &lt;put-attribute name="body" value="/WEB-INF/view/product.jsp" /&gt;
          &lt;put-attribute name="footer" value="/WEB-INF/view/footer.jsp" /&gt;
      &lt;/definition&gt;
  &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>The layout just contains one div for each part wrapping a  tag. All the views contain simple code like a header or a div.</p>
  
  <p>And for the controller
  ProductController.java:</p>
  
  <pre><code>@Controller
  @RequestMapping("/product")
  public class ProductController {
  
      protected Logger logger = Logger.getLogger(getClass());
  
      @Autowired
      private ProductService productService;
  
      @RequestMapping(value = "/{id}", method = RequestMethod.GET)
      public ModelAndView getProduct(@PathVariable Long id) {
          logger.info("GET product " + id);
          Product product = productService.find(id);
          ModelAndView mv = new ModelAndView("product_detail", "product", product);
          return mv;
      }
  }
  </code></pre>
  
  <p>Deploying this with maven embedded tomcat plugin and going to localhost:8080/myapp/product/1 just gives HTTP 400 code without any other indication that something went wrong. There is a product in the DB with that id and everything from the controller down works, as I tried it before adding tiles.</p>
  
  <p>Sorry for the code drop but I can't get this to work for some time now, and I have no idea what else to try or where to start debugging.</p>
  
  <p>Is there some way to force logging what the problem was when a 400 bad request is returned?</p>