I'm using tiles 2.0.7 with geronimo 2.1. I was playing around with the
tutorial example, and I kept getting "javax.servlet.jsp.JspException:
TilesContainer not initialized." I've got it working (by opening up
the sample .war file that comes with tiles, and copy and pasting
things around until I got something working then removing things until
I got it to break again), but I want to know why this worked. I
originally had followed the tutorial here:

http://tiles.apache.org/2.0/framework/tutorial/basic/pages.html

It was my understanding that my web.xml needed to include something
like this to get tiles to work:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID"
version="2.5">
  <display-name>my-tiles-test</display-name>

    <!-- Standard Action Servlet Configuration -->
    <servlet>
        <servlet-name>tiles</servlet-name>
        <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
        <init-param>
            <param-name>definitions-config</param-name>
            
<param-value>/WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>
</web-app>

Doing that, I got the javax.servlet.jsp.JspException: TilesContainer
not initialized error, and the only thing relevant I found in the list
archives was:

http://mail-archives.apache.org/mod_mbox/tiles-users/200802.mbox/%[email protected]%3e

Looked into the jar, verified that the path was right. Then I tried
the .war file, and it worked, so I then proceeded as mentioned
earlier. I ended up fixing it with this web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://java.sun.com/xml/ns/javaee";
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID"
version="2.5">
  <display-name>my-tiles-test</display-name>

    <!-- Standard Action Servlet Configuration -->
    <servlet>
        <servlet-name>tiles</servlet-name>
        <servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
        <init-param>
            <param-name>definitions-config</param-name>
            
<param-value>/WEB-INF/tiles-defs.xml,/org/apache/tiles/classpath-defs.xml</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        
<servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Tiles Dispatch Servlet</servlet-name>
        <url-pattern>*.tiles</url-pattern>
    </servlet-mapping>
</web-app>

I'm new to this, so it might be obvious, but any ideas why this works
and what the tutorial says doesn't? If you remove any of the <servlet>
or <servlet-mapping> statements, it comes back with the loading error.

-R

Reply via email to