2

I am trying to integrate Spring 3 and Tiles 3, I am viewing the page fine and application is working fine but its giving me following error. javax.servlet.ServletException: File "/WEB-INF/template/WEB-INF/template/layout.jsp" not found

Here are my configuration files.

<bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.tiles3.TilesView"></property>
    <property name="order" value="0"></property>
</bean>
<bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
    id="tilesConfigurer">
    <property name="definitions" value="/WEB-INF/tiles.xml"></property>
</bean>
<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:I18N/messages" />
    <property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en" />
</bean>
<mvc:interceptors>
    <mvc:interceptor>
        <mvc:mapping path="/" />
        <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang"></property>
        </bean>
    </mvc:interceptor>
</mvc:interceptors>

this is my tiles.xml

<tiles-definitions>
<definition name="base.definition"
    template='WEB-INF/template/layout.jsp'>
    <put-attribute name="title" value="" />
    <put-attribute name="header" value="/WEB-INF/tile/header.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/WEB-INF/tile/footer.jsp" />
</definition>

<definition name="login" extends="base.definition">
    <put-attribute name="title" value="login" />
    <put-attribute name="body" value="/WEB-INF/tile/login.jsp" />
</definition>

here is my layout.jsp

<body bgcolor="">
<table border="1" cellpadding="2" cellspacing="2" align="center">
    <tr>
        <td height="20%" colspan="1"><tiles:insertAttribute
                name="header" /></td>
    </tr>
    <tr>
        <td width="350"><tiles:insertAttribute name="body" /></td>
    </tr>
    <tr>
        <td height="10%" colspan="1"><tiles:insertAttribute
                name="footer" /></td>
    </tr>
</table>

What am I doing wrong here? I spent hours on it, still cant figure it out.

varun
  • 684
  • 1
  • 11
  • 30

1 Answers1

0

Look at exception:

javax.servlet.ServletException: File &quot;/WEB-INF/template/WEB-INF/template/layout.jsp&quot; not found

Tiles tries to find "layout.js" at /WEB-INF/template/WEB-INF/template.

In

<definition name="base.definition"
    template='WEB-INF/template/layout.jsp'>

Try to add "/" before template path:

<definition name="base.definition"
    template='/WEB-INF/template/layout.jsp'>
yname
  • 2,189
  • 13
  • 23
  • It used to be like that in the first place, but i was getting a more severe error. it rendered my tiles multiple times and resulted in stack overflow. – varun Aug 17 '13 at 10:38
  • Please add layout.jsp and other pages to your question to have more information – yname Aug 17 '13 at 10:46
  • i added layout.jsp, please have alook – varun Aug 17 '13 at 10:52
  • All looks fine. Just a try: try to remove put-attribute with empty value (title and body). In case of "attribute not defined" exception use ignore="true" attribute: . After that changes - still infinite loop and stack overflow? – yname Aug 17 '13 at 11:08
  • And look at this: http://stackoverflow.com/questions/15781574/server-goes-into-infinite-loop-while-implementing-tiles-with-velocity – yname Aug 17 '13 at 11:09
  • i made changes as you said, its still same error. Its driving me nuts. – varun Aug 17 '13 at 11:32
  • Tried to add at the end of tiles.xml as mentioned at link? – yname Aug 17 '13 at 11:34
  • Sorry, I have no ideas what is it. – yname Aug 17 '13 at 11:54
  • no problem man. suggest me a similar technology to use with spring MVC, I am already seeing too many problems with this. – varun Aug 17 '13 at 12:05
  • I want to make reusable view components – varun Aug 17 '13 at 12:06