title: Spring MVC with Tiles 3 NullPointerException
body: <p>I've tried everything and it is quite possible that I have problem with some basic understanding of my problem. I try to run Tiles 3 with Spring MVC, here is my project files:</p>
  <h3>web.xml</h3>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
   
  &lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/lib/spring-servlet.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
       
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
   
  &lt;/web-app&gt;
  </code></pre>
  <h3>spring-servlet.xml</h3>
  <pre><code>&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;  
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;  
  xmlns:p=&quot;http://www.springframework.org/schema/p&quot;  
  xmlns:context=&quot;http://www.springframework.org/schema/context&quot;  
  xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans  
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
      http://www.springframework.org/schema/context  
      http://www.springframework.org/schema/context/spring-context-3.0.xsd&quot;&gt;
  
  &lt;bean id=&quot;tilesViewResolver&quot;
        class=&quot;org.springframework.web.servlet.view.tiles3.TilesViewResolver&quot;&gt;
          &lt;property name=&quot;order&quot; value=&quot;0&quot; /&gt; &lt;!-- you need to tell spring to use this resolver first, hence order=0 --&gt;
  &lt;/bean&gt;
  
  &lt;bean id=&quot;viewResolver&quot;
          class=&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;&gt;
          &lt;property name=&quot;order&quot; value=&quot;1&quot; /&gt;&lt;!-- this resolver will be used if the view can't be resolved by tiles resolver  hence order=1--&gt;
          &lt;property name=&quot;prefix&quot; value=&quot;/WEB-INF/jsp/&quot; /&gt;
          &lt;property name=&quot;suffix&quot; value=&quot;.jsp&quot; /&gt;
  &lt;/bean&gt;
    
  &lt;bean id=&quot;tilesConfigurer&quot;  
      class=&quot;org.springframework.web.servlet.view.tiles3.TilesConfigurer&quot;&gt;  
      &lt;property name=&quot;definitions&quot; value=&quot;/WEB-INF/lib/tiles.xml&quot; /&gt; 
  &lt;/bean&gt;  
  &lt;/beans&gt;
  </code></pre>
  <h3>tiles.xml</h3>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
  &lt;!DOCTYPE tiles-definitions PUBLIC
    &quot;-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN&quot; 
    &quot;http://tiles.apache.org/dtds/tiles-config_3_0.dtd&quot;&gt;
  &lt;tiles-definitions&gt;
  &lt;definition name=&quot;home&quot; template=&quot;/WEB-INF/jsp/home.jsp&quot;&gt;
      &lt;put-attribute name=&quot;header&quot; value=&quot;/WEB-INF/jsp/header.jsp&quot; /&gt;
  &lt;/definition&gt;
  &lt;/tiles-definitions&gt;
  </code></pre>
  <h3>home.jsp</h3>
  <pre><code>&lt;%@ taglib uri=&quot;http://tiles.apache.org/tags-tiles&quot; prefix=&quot;tiles&quot; %&gt;
   
  &lt;tiles:insertDefinition name=&quot;home&quot; /&gt;
  
  &lt;tiles:insertAttribute name=&quot;header&quot; /&gt;
  </code></pre>
  <h3>HomeController.java</h3>
  <pre><code>import java.util.Map;
  
  import javax.servlet.http.HttpSession;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  @Controller
  @EnableAutoConfiguration
  public class HomeController {
  
  @RequestMapping(&quot;/&quot;)
  String home_login(Map&lt;String, Object&gt; model, HttpSession session) {
      return &quot;home&quot;;
  }
  
  public static void main(String[] args) throws Exception {
      SpringApplication.run(HomeController.class, args);
  }
  }
  </code></pre>
  <p>Stack trace:</p>
  <pre><code>2015-08-11 16:02:40.840  INFO 1324 --- [           main] c.p.noodle.controller.HomeController     : Started HomeController in 2.513 seconds (JVM running for 2.818)
  2015-08-11 16:02:48.436  INFO 1324 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
  2015-08-11 16:02:48.436  INFO 1324 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
  2015-08-11 16:02:48.452  INFO 1324 --- [nio-8081-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
  2015-08-11 16:02:48.936 ERROR 1324 --- [nio-8081-exec-1] o.a.c.c.C.[.[localhost].[/].[jsp]        : Servlet.service() for servlet jsp threw exception
  
  java.lang.NullPointerException: null
  at org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:124)
  at org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:107)
  at org.apache.tiles.access.TilesAccess.getCurrentContainer(TilesAccess.java:174)
  at org.apache.tiles.template.InsertDefinitionModel.execute(InsertDefinitionModel.java:95)
  at org.apache.tiles.jsp.taglib.InsertDefinitionTag.doTag(InsertDefinitionTag.java:254)
  at org.apache.jsp.WEB_002dINF.jsp.home_jsp._jspx_meth_tiles_005finsertDefinition_005f0(home_jsp.java:134)
  at org.apache.jsp.WEB_002dINF.jsp.home_jsp._jspService(home_jsp.java:98)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
  at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
  at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
  at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
  at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Unknown Source)
  
  2015-08-11 16:02:48.940 ERROR 1324 --- [nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [An exception occurred processing JSP page /WEB-INF/jsp/home.jsp at line 3
  
  1: &lt;%@ taglib uri=&quot;http://tiles.apache.org/tags-tiles&quot; prefix=&quot;tiles&quot; %&gt;
  2:  
  3:  &lt;tiles:insertDefinition name=&quot;home&quot; /&gt;
  4: 
  5:    &lt;tiles:insertAttribute name=&quot;header&quot; /&gt;
  
  
  Stacktrace:] with root cause
  
  java.lang.NullPointerException: null
  at org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:124)
  at org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:107)
  at org.apache.tiles.access.TilesAccess.getCurrentContainer(TilesAccess.java:174)
  at org.apache.tiles.template.InsertDefinitionModel.execute(InsertDefinitionModel.java:95)
  at org.apache.tiles.jsp.taglib.InsertDefinitionTag.doTag(InsertDefinitionTag.java:254)
  at org.apache.jsp.WEB_002dINF.jsp.home_jsp._jspx_meth_tiles_005finsertDefinition_005f0(home_jsp.java:134)
  at org.apache.jsp.WEB_002dINF.jsp.home_jsp._jspService(home_jsp.java:98)
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:721)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:466)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
  at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
  at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
  at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
  at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  <p>Every help will be appreciated!</p>
  <h3>Edit: I forget to mention that I'm running it with Spring Boot.</h3>