I am using struts2+hibernate integration for my project and had implemented tiles in this, but faced this issue

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <constant name="struts.devMode" value="true" />

    <package name="default" extends="hibernate-default">

        <result-types>
            <result-type name="tiles"
                class="org.apache.struts2.views.tiles.TilesResult" />
        </result-types>

        <action name="*Menu" method="{1}"
            class="com.struts2hibernatepagination.action.MenuAction">
            <result name="tiger" type="tiles">tiger</result>
            <result name="lion" type="tiles">lion</result>
        </action>

        <action name="addStudent" method="execute"
            class="com.struts2hibernatepagination.action.AddStudentAction">
            <interceptor-ref name="defaultStackHibernateStrutsValidation">
                <param name="validation.excludeMethods">listStudents</param>
                <param name="validation.excludeMethods">fetchStudentList</param>
            </interceptor-ref>
            <result name="success" type="redirect">
                listStudents
            </result>
            <result name="input">/student.jsp</result>
        </action>

        <action name="listStudents" method="listStudents"
            class="com.struts2hibernatepagination.action.AddStudentAction">
            <interceptor-ref name="basicStackHibernate" />
            <result name="success">/student.jsp</result>
            <result name="input">/student.jsp</result>
        </action>

        <action name="fetchStudentList"
            class="com.struts2hibernatepagination.action.AddStudentAction"
            method="listStudents">
            <interceptor-ref name="basicStackHibernate" />
            <result name="success">/displaytag.jsp</result>
            <result name="input">/student.jsp</result>
        </action>

        <action name="listStudentByName"
            class="com.struts2hibernatepagination.action.AddStudentAction"
            method="edit">
            <interceptor-ref name="basicStackHibernate" />
            <result name="success">/searchStudent.jsp</result>
            <result name="input">/searchStudent.jsp</result>
        </action>

        <action name="studentFirstNameList"
            class="com.struts2hibernatepagination.action.AddStudentAction"
            method="studentFirstName">
            <interceptor-ref name="basicStackHibernate" />
            <result name="success">/searchStudent.jsp</result>
        </action>

    </package>
</struts>

tiles.xml

<?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_2.dtd">

<tiles-definitions>

    <definition name="baseLayout" template="/baseLayout.jsp">
        <put-attribute name="title" value="Template" />
        <put-attribute name="banner" value="/banner.jsp" />
        <put-attribute name="menu" value="/menu.jsp" />
        <put-attribute name="body" value="/body.jsp" />
        <put-attribute name="footer" value="/footer.jsp" />
    </definition>

    <definition name="tiger" extends="baseLayout">
        <put-attribute name="title" value="Tiger" />
        <put-attribute name="body" value="/tiger.jsp" />
    </definition>

    <definition name="lion" extends="baseLayout">
        <put-attribute name="title" value="Lion" />
        <put-attribute name="body" value="/lion.jsp" />
    </definition>

</tiles-definitions>

web.xml

<?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>Struts2Example17</display-name>

    <context-param>
   <param-name>
      org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
   </param-name>
   <param-value>
      /WEB-INF/tiles.xml
   </param-value>
   </context-param>

    <listener>
   <listener-class>
      org.apache.struts2.tiles.StrutsTilesListener
   </listener-class>
   </listener>


    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>student.jsp</welcome-file>
    </welcome-file-list>
</web-app>

MenuAction.java

package com.struts2hibernatepagination.action;

import com.opensymphony.xwork2.ActionSupport;

public class MenuAction extends ActionSupport {

    public String tiger() {
        return "tiger";
    }

    public String lion() {
        return "lion";
    }

}

banner.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<img src="http://www.tutorialspoint.com/images/tp-logo.gif"/>
</body>
</html>

baseLayout.jsp

<%@ 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=ISO-8859-1">
<title><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
    <tiles:insertAttribute name="banner" />
    <br />
    <hr />
    <tiles:insertAttribute name="menu" />
    <br />
    <hr />
    <tiles:insertAttribute name="body" />
    <br />
    <hr />
    <tiles:insertAttribute name="footer" />
    <br />
</body>
</html>

lion.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<img src="http://upload.wikimedia.org/wikipedia/commons/d/d2/Lion.jpg"/>
The lion
</body>
</html>

menu.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <a href="<s:url action="tigerMenu"/>">Tiger</a>
    <br>
    <a href="<s:url action="lionMenu"/>">Lion</a>
    <br>
</body>
</html>

tiger.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <img src="http://www.freewebs.com/tigerofdarts/tiger.jpg" /> The tiger
</body>
</html>

List of libraries which I have used in my project

enter image description here

Here is the snap after I try to access http://localhost:8080/Struts2HibernatePagination/tigerMenu.action

Can somebody please tell me why I am getting this exception as I am stuck with this from last 2 days, and had tried alot to change various libraries but nothing worked!!.. Please help !! :(

1

There are 1 best solutions below

1
On

I have replaced the libraries with

  1. struts2-tiles-plugin-2.1.6.jar
  2. tiles-api-2.1.2.jar
  3. tiles-compat-2.1.2.jar
  4. tiles-core-2.1.2.jar
  5. tiles-jsp-2.1.2.jar
  6. tiles-servlet-2.1.2.jar

and it worked!

It was not working with tiles 2.2 jars