Announcement Announcement Module
Collapse
No announcement yet.
Using Tiles with MVC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Tiles with MVC

    I've been working on this all day, but I can't find a solution.

    I've found a few tutorials on the net, but none of them seem to work. I wanted to use Tiles2, as the reference guide of Spring tells you to, but for some reason I get a rather strange error.

    I've added Spring and Spring-Webmvc as a dependency to my application. I also added a dependency to commons-beanutils, commons-digester and commons-logging and 1 for Tiles:

    Code:
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
    </dependency>
    
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
    </dependency>
    Spring dependencies:
    Code:
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.5</version>
    </dependency>
    
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>2.5.5</version>
    </dependency>
    I've changed my Spring configuration and added Tiles to it:

    Code:
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-def.xml</value>
            </list>
        </property>
    </bean>
    
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
    </bean>
    When I deploy my application on Weblogic, I get the following error:

    Code:
    [ERROR]-[08-10-2008-16:13]-[org.springframework.web.servlet.DispatcherServlet]-<Context initialization failed>@line290
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/app-servlet.xml]: Invocation of init method failed; nested exception is org.apache.tiles.definition.DefinitionsFactoryException: I/O Error reading definitions.
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1337)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    A bit further:
    Code:
    Caused by: org.apache.tiles.definition.DefinitionsFactoryException: I/O Error reading definitions.
    Does anyone have any idea what I'm doing wrong? Which dependencies do I have to add to make this work? Or a working example, which I can use as a starting point for this. Most examples I find on the net still use Tiles instead of Tiles 2.

  • #2
    Here's my config...it's almost identical to yours (I can't speak to the maven dependencies as we use Ant).

    Code:
        <bean id="tilesConfigurer"  class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/tiles-defs.xml</value>
                </list>
            </property>
        </bean>
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="order" value="1"/>
            <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
        </bean>
    Are you sure that your tiles-def file is in the deployment archive? Have you unjarred it to check?

    Comment


    • #3
      My mistake. I forgot to change the dtd for the tiles definition. When that's correct, it works.

      Comment

      Working...
      X