I'm integrated Tiles with Struts2 web application in Windows 8 OS. I am getting the following error in server log:
java.lang.NoClassDefFoundError: org/apache/tiles/web/startup/TilesListener
java.lang.ClassNotFoundException: org.apache.tiles.web.startup.TilesListener
I used the following necessary jars:
xwork-core-2.3.15.3.jar
struts2-core-2.3.15.3.jar
struts2-convention-plugin-2.3.15.3.jar
ognl-3.0.6.jar
javassist-3.11.0.GA.jar
freemarker-2.3.19.jar
commons-lang3-3.1.jar
commons-io-2.0.1.jar
commons-fileupload-1.3.jar
load-1.3.jar
asm-tree-3.3.jar
asm-commons-3.3.jar
asm-3.3.jar
tiles-api-2.0.6-sources.jar
tiles-compat-3.0.5.jar
tiles-core-2.0.6-sources.jar
tiles-jsp-3.0.5.jar
tiles-servlet-3.0.5.jar
tiles-portlet-2.1.4.jar
struts2-tiles-plugin-2.3.15.1..jar
My web.xml
configuration:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<welcome-file-list>
<welcome-file>/Login.jsp</welcome-file>
</welcome-file-list>
<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>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
my tiles.xml
configuration:
<?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="BaseLayout" template="/BaseLayout.jsp">
<put-attribute name="title" value=" " />
<put-attribute name="header" value="/Header.jsp" />
<put-attribute name="menu" value="/Menu.jsp" />
<put-attribute name="body" value=" " />
<put-attribute name="footer" value="/Footer.jsp" />
</definition>
<definition name="/daywise.success.tiles" extends="BaseLayout">
<put-attribute name="body" value="/BodyDayWiseSuccess.jsp" />
</definition>
<definition name="/daywise.tiles" extends="BaseLayout">
<put-attribute name="body" value="/BodyDayWise.jsp" />
</definition>
</tiles-definitions>
what am I missing? I already spent a full day searching in google for a possible solution but not getting the right one.
You are missing a class. You are needed a class org.apache.tiles.web.startup.TilesListener
but this file is found in the tiles-core-2.0.6.jar. This file you are missing.
If you don't want to download each file from the web, use Maven configuration in pom.xml
like using the link below. Maven will download all required dependencies when you build the project using a command:
mvn package
Beside this a lot of errors are in the project files an configuration:
If you can't find links for Struts2 and Tiles2 integration you can read this answer, it has a lot of links with code examples.