org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found

4.1k views Asked by At

i search every post on this question but didn't get an answer.please help me to solve this problem quickly.

i used spring 3.1.1 and tile2.2.2.but running the project i got an error like follows :

org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
    at org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:49)
    at org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:187)
    at org.apache.tiles.template.InsertAttributeModel.start(InsertAttributeModel.java:107)
    at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
    at org.apache.jsp.WEB_002dINF.jsp.main_jsp._jspx_meth_tiles_005finsertAttribute_005f1(main_jsp.java:134)
    at org.apache.jsp.WEB_002dINF.jsp.main_jsp._jspService(main_jsp.java:75)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
Jun 11, 2015 10:37:19 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [spring] in context with path [/Spring3HibernateMaven] threw exception [org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.] with root cause
org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
    at org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:49)
    at org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:187)
    at org.apache.tiles.template.InsertAttributeModel.start(InsertAttributeModel.java:107)
    at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:306)
    at org.apache.jsp.WEB_002dINF.jsp.main_jsp._jspx_meth_tiles_005finsertAttribute_005f1(main_jsp.java:134)
    at org.apache.jsp.WEB_002dINF.jsp.main_jsp._jspService(main_jsp.java:75)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)

tile.xml as follows :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC  
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"  
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">  
<tiles-definitions>  
    <definition name="base.definition"  
        template="/WEB-INF/jsp/main.jsp">  
        <put-attribute name="title" value="" />  
        <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />  
        <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />  
        <put-attribute name="body" value="" />  
        <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />  
    </definition>  

    <definition name="userRedirect" extends="base.definition">

        <put-attribute name="title" value="User Management" />          
        <put-attribute name="body" value="/WEB-INF/jsp/UserManagement.jsp" />   

    </definition>  

    <definition name="usertype" extends="base.definition"> 

        <put-attribute name="title" value="User Type Management" />         
        <put-attribute name="body" value="/WEB-INF/jsp/UserTypeManagement.jsp" />   


    </definition>  

</tiles-definitions>  

main.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title><tiles:insertAttribute name="title" ignore="true" /></title>  
</head>  
<body>  
        <div><tiles:insertAttribute name="header" /></div>  
        <div style="float:left;padding:10px;width:15%;"><tiles:insertAttribute name="menu" /></div>  
        <div style="float:left;padding:10px;width:80%;border-left:1px solid pink;">  
        <tiles:insertAttribute name="body" /></div>  
        <div style="clear:both"><tiles:insertAttribute name="footer" /></div>  

</body>  
</html>

spring-servlet.xml

<bean id="jspViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>
<bean id="viewResolver"  
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">  
        <property name="viewClass">  
            <value>  
                org.springframework.web.servlet.view.tiles2.TilesView  
            </value>  
        </property>  
    </bean>  
    <bean id="tilesConfigurer"  
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">  
        <property name="definitions">  
            <list>  
                <value>/WEB-INF/tiles.xml</value>  
            </list>  
        </property>  
    </bean> 
1

There are 1 answers

0
nimaya On BEST ANSWER

i commented below lines on servlet.xml

 <!--<bean id="jspViewResolver"-->
        <!--class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
        <!--<property name="viewClass"-->
            <!--value="org.springframework.web.servlet.view.JstlView" />-->
        <!--<property name="prefix" value="/WEB-INF/jsp/" />-->
        <!--<property name="suffix" value=".jsp" />-->
    <!--</bean> -->

tile.xml as follows :

<definition name="base.definition"  
        template="/WEB-INF/jsp/main.jsp">  
        <put-attribute name="title" value="" />  
        <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />  
        <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />  
        <put-attribute name="body" value="" />  
        <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />  
    </definition>  

    <definition name="loginform" template="/WEB-INF/jsp/loginform.jsp"/>

    <definition name="userRedirect" extends="base.definition">
        <put-attribute name="title"  value="User Management" />
        <put-attribute name="body" value="/WEB-INF/jsp/UserManagement.jsp" />
    </definition>

    <definition name="usertype" extends="base.definition">     
        <put-attribute name="title"  value="User Type Management" />         
        <put-attribute name="body" value="/WEB-INF/jsp/UserTypeManagement.jsp" />            
    </definition>

    <definition name="Loginsucess" extends="base.definition">
        <put-attribute name="title"  value="Simple Tiles 2 Example"/>
        <put-attribute name="body" value="/WEB-INF/jsp/UserTypeManagement.jsp" />          
    </definition> 

controllers as follows :

@RequestMapping("/Loginsucess")
    public String sucessRedirect(Model model) {

        model.addAttribute("User", new User()); 
        return "Loginsucess";
    }

@RequestMapping("/userRedirect")
    public String listContacts(/*Model model*/) {

        //model.addAttribute("User", new User()); 
        return "userRedirect";
    }
@RequestMapping("/usertype")
    public String listContacts(/*Model model*/) {

        //model.addAttribute("User", new User()); 
        return "usertype";
    }