Struts 2 Tiles Plugin Tutorial with Example in Eclipse

Welcome to Part-4 of the 7-part series where we will go through different aspects for Struts2 Framework with some useful examples. In previous part we went through Struts2 Validation Framework. We saw how easy it is to integrate validation in your struts2 application.

In this part we will discuss about Tiles Framework and its Integration with Struts2. We will add Tiles support to our HelloWorld Struts application that we created in previous parts. I strongly recommend you to go through previous articles and download the source code of our sample application.

Introduction to Tiles 2

Nowadays, website are generally divided into pieces of reusable template that are being rendered among different web pages. For example a site containing header, footer, menu etc. This items remains same through out the website and give it a common look and feel. It is very difficult to hard code this in each and every webpage and if later a change is needed than all the pages needs to be modified. Hence we use templatization mechanism. We create a common Header, Footer, Menu page and include this in each page.

Tiles Plugin allow both templating and componentization. In fact, both mechanisms are similar: you
define parts of page (a “Tile”) that you assemble to build another part or a full page. A part can
take parameters, allowing dynamic content, and can be seen as a method in JAVA language. Tiles is a templating system used to maintain a consistent look and feel across all the web pages of a web application. It increase the reusability of template and reduce code duplication.

A common layout of website is defined in a central configuration file and this layout can be extended across all the webpages of the web application.

Our Application Layout

Our goal is to add Header, Footer and Menu to our StrutsHelloWorld application. Following will be the layout of the same.
struts2-tiles-layout

Required JAR files

In order to add Tiles support to our Struts2 application, we will need few jar files. Following is the list of JARs in our example. Add these JARs in WEB-INF/lib folder.
struts2-tiles-jar-files

Configuring Tiles in web.xml

To configure Tiles, an entry for listener has to be made in web.xml. Open the web.xml from WEB-INF folder and add following code into it.

	<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>

The above code configure Tiles listener in web.xml. An input configuration file /WEB-INF/tiles.xml is passed as argument. This file contains the Tiles definition for our web application.

Create a file tiles.xml in WEB-INF folder and copy following code into it.
struts2-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_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="/welcome.tiles" extends="baseLayout">
		<put-attribute name="title" value="Welcome" />
		<put-attribute name="body" value="/Welcome.jsp" />
	</definition>
	<definition name="/customer.tiles" extends="baseLayout">
		<put-attribute name="title" value="Customer Form" />
		<put-attribute name="body" value="/Customer.jsp" />
	</definition>
	<definition name="/customer.success.tiles" extends="baseLayout">
		<put-attribute name="title" value="Customer Added" />
		<put-attribute name="body" value="/SuccessCustomer.jsp" />
	</definition>
</tiles-definitions>

Here in tiles.xml we have define a template baseLayout. This layout contains attributes such as Header, Title, Body, Menu and Footer. The layout is then extended and new definitions for Welcome page and Customer page is defined. We have override the default layout and changed the content for Body and Title.

Creating JSPs

struts-2-tiles-layout-jspWe will define the template for our webapplication in a JSP file called BaseLayout.jsp. This template will contain different segments of web page (Header, Footer, Menu etc). Create 4 new JSP files BaseLayout.jsp, Header.jsp, Menu.jsp and Footer.jsp and copy following content in each of them.
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=UTF-8">
<title><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
<table border="1" cellpadding="2" cellspacing="2" align="center">
	<tr>
		<td height="30" colspan="2"><tiles:insertAttribute name="header" />
		</td>
	</tr>
	<tr>
		<td height="250"><tiles:insertAttribute name="menu" /></td>
		<td width="350"><tiles:insertAttribute name="body" /></td>
	</tr>
	<tr>
		<td height="30" colspan="2"><tiles:insertAttribute name="footer" />
		</td>
	</tr>
</table>
</body>
</html>

Header.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<h2>Struts2 Example - ViralPatel.net</h2>

Menu.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:a href="customer-form">Customer</s:a>

Footer.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
Copyright &copy; ViralPatel.net

Modifications in Struts.xml

In struts.xml we defined result tag which maps a particular action with a JSP page. Now we will modify it and map the result with Tiles. Following will be the content of struts.xml file.

<?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.enable.DynamicMethodInvocation"
		value="false" />
	<constant name="struts.devMode" value="false" />
	<constant name="struts.custom.i18n.resources"
		value="ApplicationResources" />

	<package name="default" extends="struts-default" namespace="/">
		<result-types>
			<result-type name="tiles"
				class="org.apache.struts2.views.tiles.TilesResult" />
		</result-types>
		<action name="login" 
			class="net.viralpatel.struts2.LoginAction">
			<result name="success" type="tiles">/welcome.tiles</result>
			<result name="error">Login.jsp</result>
		</action>
		<action name="customer" 
			class="net.viralpatel.struts2.CustomerAction">
			<result name="success" type="tiles">/customer.success.tiles</result>
			<result name="input" type="tiles">/customer.tiles</result>
		</action>
		<action name="customer-form">
			<result name="success" type="tiles">/customer.tiles</result>
		</action>
	</package>
</struts>

The struts.xml now defines a new Result type for Tiles. This result type is used in <result> tag for different actions. Also note that we have define a new action customer-form. This is just an empty declaration to redirect user to Customer form page when she clicks Customer link from menu.

That’s All Folks

Compile and Execute the application in Eclipse and see that the header, menu and footer are properly applied.
Welcome Page with Tiles
struts-2-welcome-page-tiles
Customer Page with Tiles
struts2-tiles-customer-page
Customer Success Page with Tiles
struts2-customer-added-tiles

Download Source Code

Click here to download Source Code without JAR files (11KB)

Moving On

Today we saw how we can configure Tiles framework with Struts2 application. In next part we will discuss about Struts2 Interceptors and see example of it. I hope you liked this article. Feel free to post your queries and comments in comment section.

Get our Articles via Email. Enter your email address.

You may also like...

88 Comments

  1. spatil says:

    Hi Viral,

    Thanks a lot for you..
    Actually the tutorial is very helpful .
    what ‘m facing is ,whenever i download the code and setup in the eclipse ,it s working fine.but if do setup by myself throwing an error like The requested resource () is not available.
    please help me to resolve this issue.
    Thanks in advance.

    • sachin says:

      heyy frnd just check ur class name is correct according to ur package………..

  2. TranLong says:

    i like your`document which you give me. thank you.

  3. zain says:

    hi guys,this is zain i am devlp project, getting frustrated because of this ERROR can somebody help me…plz

    Mar 2, 2013 12:00:04 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener
    java.lang.NullPointerException
    	at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
    	at org.apache.commons.digester.Digester.parse(Digester.java:1887)
    	at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:267)
    	at org.apache.tiles.definition.UrlDefinitionsFactory.readDefinitions(UrlDefinitionsFactory.java:286)
    	at org.apache.tiles.definition.UrlDefinitionsFactory.init(UrlDefinitionsFactory.java:130)
    	at org.apache.tiles.impl.BasicTilesContainer.initializeDefinitionsFactory(BasicTilesContainer.java:406)
    	at org.apache.tiles.impl.BasicTilesContainer.init(BasicTilesContainer.java:130)
    	at org.apache.tiles.factory.TilesContainerFactory.initializeContainer(TilesContainerFactory.java:232)
    	at org.apache.tiles.factory.TilesContainerFactory.createTilesContainer(TilesContainerFactory.java:198)
    	at org.apache.tiles.factory.TilesContainerFactory.createContainer(TilesContainerFactory.java:163)
    	at org.apache.tiles.web.startup.TilesListener.createContainer(TilesListener.java:90)
    	at org.apache.struts2.tiles.StrutsTilesListener.createContainer(StrutsTilesListener.java:70)
    	at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:57)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Mar 2, 2013 12:00:04 PM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    
    • venkat says:

      Hi zain,

      I am also facing the same issue.
      if u got any solution please help me.

      Thanks,
      venkat

  4. sayali says:

    can i use tiles in MVC2 architecture????
    pls rpl me…

  5. dan says:

    This is great. u have made me more confident in this profession. Thanks.

  6. venkat says:

    HI,
    Getting the following errors.
    Please Help to resolve the issue.

    Thanks
    Venkat
    Mar 21, 2013 12:41:52 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Documents and Settings\Administrator\MyEclipse Professional\binary\com.sun.java.jdk.win32.x86_1.6.0.u43\bin;C:\Documents and Settings\Administrator\MyEclipse Professional\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_11.0.0.me201211151802\tomcat\bin
    Mar 21, 2013 12:41:52 PM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Mar 21, 2013 12:41:52 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 305 ms
    Mar 21, 2013 12:41:52 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Mar 21, 2013 12:41:52 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.13
    log4j:WARN No appenders could be found for logger (org.apache.tiles.impl.BasicTilesContainer).
    log4j:WARN Please initialize the log4j system properly.
    Mar 21, 2013 12:41:54 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener
    java.lang.NullPointerException
    at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058)
    at org.apache.commons.digester.Digester.parse(Digester.java:1887)
    at org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(DigesterDefinitionsReader.java:267)
    at org.apache.tiles.definition.UrlDefinitionsFactory.readDefinitions(UrlDefinitionsFactory.java:286)
    at org.apache.tiles.definition.UrlDefinitionsFactory.init(UrlDefinitionsFactory.java:130)
    at org.apache.tiles.impl.BasicTilesContainer.initializeDefinitionsFactory(BasicTilesContainer.java:406)
    at org.apache.tiles.impl.BasicTilesContainer.init(BasicTilesContainer.java:130)
    at org.apache.tiles.factory.TilesContainerFactory.initializeContainer(TilesContainerFactory.java:232)
    at org.apache.tiles.factory.TilesContainerFactory.createTilesContainer(TilesContainerFactory.java:198)
    at org.apache.tiles.factory.TilesContainerFactory.createContainer(TilesContainerFactory.java:163)
    at org.apache.tiles.web.startup.TilesListener.createContainer(TilesListener.java:90)
    at org.apache.struts2.tiles.StrutsTilesListener.createContainer(StrutsTilesListener.java:68)
    at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:57)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Mar 21, 2013 12:41:54 PM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Mar 21, 2013 12:41:54 PM org.apache.catalina.core.StandardContext start
    SEVERE: Context [/StrutsHelloWorld] startup failed due to previous errors
    Mar 21, 2013 12:41:54 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    Mar 21, 2013 12:41:54 PM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    Mar 21, 2013 12:41:55 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/16 config=null
    Mar 21, 2013 12:41:55 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 2316 ms

    • Srikanth Kattam says:

      Hi Venkat,

      Make sure all your tiles related jars are of same version and is matching with that of the version mentioned in tiles.xml ( i.e. “http://tiles.apache.org/dtds/tiles-config_.dtd”).

      For Instance: tiles.xml containing “http://tiles.apache.org/dtds/tiles-config_2_0.dtd” should have following jars in the project library:

      struts2-tiles-plugin-2.0.11.jar,
      tiles-api.2.0.6.jar,
      tiles-jsp-2.0.6.jar,
      tiles-core-2.0.6.jar

      Cheers :)

  7. ailing says:

    org.apache.tiles.TilesException: Attribute ‘header’ not found.
    at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:112)
    at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:154)
    at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:75)
    at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:80)
    at org.apache.jsp.BaseLayout_jsp._jspx_meth_tiles_005finsertAttribute_005f1(BaseLayout_jsp.java:145)
    at org.apache.jsp.BaseLayout_jsp._jspService(BaseLayout_jsp.java:75)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703)
    at java.lang.Thread.run(Thread.java:619)

  8. Prateek says:

    The tutorial is superb and your way of explaining is excellent.Thanks a lot.

  9. alok says:

    hey viral, could please explain how to integrate struts 2.1 + hibernate 3.5 and tiles 2.06 together it shows error!
    1) “tiles-definitions”, must match DOCTYPE root “struts”
    2)XML error reading definitions.
    3)Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener
    Unable to instantiate container.

    [ code java ]
    web.xml

    org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG

    /WEB-INF/tiles.xml

    org.apache.struts2.tiles.StrutsTilesListener

    struts2
    org.apache.struts2.dispatcher.FilterDispatcher

    struts2
    /*

    index.jsp

    tiles.xml

    struts.xml

    welcome
    page1
    page2

    // rest is jsp code

    [ / code ]

  10. veena says:

    Hai Viral,
    This tutorial is very much helpful for me ..Thanks a lot.

  11. sathish says:

    how to install struts2.3 final version in eclipse juno please any body is there to help me regarding in this please

  12. Venkat says:

    Hi Viral,
    Great tutorial.
    The tiles are being loaded only if if the page is loaded a part of result from an action class.is it possible to load the page with tiles when a link is clicked i.e without going through an action.
    Thanks in advance.

  13. jagnya says:

    When i run this application i got an erron in my console :
    [
    SEVERE: Dispatcher initialization failed
    Unable to load configuration. – bean – jar:file:/D:/jagnya%20eclips/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TilesFrameWork/WEB-INF/lib/struts2-gxp-plugin-2.3.15.2.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer – bean – jar:file:/D:/jagnya%20eclips/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TilesFrameWork/WEB-INF/lib/struts2-gxp-plugin-2.3.15.2.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    … 17 more
    Caused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainer
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    … 20 more
    Oct 25, 2013 10:57:47 AM org.apache.catalina.core.StandardContext filterStart
    SEVERE: Exception starting filter struts2
    Unable to load configuration. – bean – jar:file:/D:/jagnya%20eclips/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TilesFrameWork/WEB-INF/lib/struts2-gxp-plugin-2.3.15.2.jar!/struts-plugin.xml:8:162
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:502)
    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
    at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:107)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: Unable to load configuration. – bean – jar:file:/D:/jagnya%20eclips/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TilesFrameWork/WEB-INF/lib/struts2-gxp-plugin-2.3.15.2.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
    … 15 more
    Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer – bean – jar:file:/D:/jagnya%20eclips/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TilesFrameWork/WEB-INF/lib/struts2-gxp-plugin-2.3.15.2.jar!/struts-plugin.xml:8:162
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:226)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
    … 17 more
    Caused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainer
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
    … 20 more
    >]

  14. jagnya says:

    Please me to solve This above problem……………

  15. Anand says:

    Hi Viral,
    Thanks for the tutorial. Its really teaching a lot. Can we have any other part in struts2 which was not mentioned in ur tutorial?

  16. Dhirajkumar Rameshchand Jaiswal says:

    Dear Friend,

    You explained good. Thanks!!! but I will appreciate you is you can provide the source code with jars. Hope I am not expecting spoon feeding.

    Regards
    -Dhirajkumar

  17. Vicky Radaur says:

    Good Job Dude. Quite Simplified way . Thanks :)

  18. ranjeet says:

    Please suggest from which website i will be able to take struts 2 jar file for example Tile support

  19. Alex says:

    great tutorial , thanks for sharing sir!

  20. Ramesh jangid says:

    i am creating web page by using tiles.but i have not some tiles jar file. pls suggestion me.what way i can download jar file.

  21. Antonio Petricca says:

    Is it possibile to nest definition by that old release?

  22. murali says:

    hi … i am followed the same, its fine.i got doubt in tiles when ever we are loading next page, in page title its showing that localhost/ ip address. how can i disable that ip address/localhost .
    its happening after next button and before page loading… can u tell how to resolve this, i checked with gmail.. in that its giving some thing like”Please wait while page loading….”

  23. rishi says:

    Hi Viral,

    Very thanks for the tutorial, but I am having this kind of error

    org.apache.tiles.definition.NoSuchDefinitionException: /welcome.tiles

    Please help me resolve this

    Thanks in advance

    • andriun says:

      Hi rishi, I had the same problem and I fixed it checking the name in struts.xml file. I wrote “Welcome.tiles” rather “welcome.tiles”. I hope it’s working well for you.

  24. Nancy says:

    HTTP Status 404 – /StrutsTiles/

    ——————————————————————————–

    type Status report

    message /StrutsTiles/

    description The requested resource is not available.

    ——————————————————————————–

    Apache Tomcat/6.0.41

  25. thandar says:

    When I run this code I got this error code ::

    SEVERE: Error configuring application listener of class org.apache.struts2.tiles.StrutsTilesListener
    java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
    at com.opensymphony.xwork2.util.logging.commons.CommonsLoggerFactory.getLoggerImpl(CommonsLoggerFactory.java:18)
    at com.opensymphony.xwork2.util.logging.LoggerFactory.getLogger(LoggerFactory.java:31)
    at org.apache.struts2.tiles.StrutsTilesListener.(StrutsTilesListener.java:50)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    … 21 more

  26. katoch says:

    HTTP Status 404 – /StrutsHelloWorld/

    ——————————————————————————–

    type Status report

    message /StrutsHelloWorld/

    description The requested resource is not available.

    ——————————————————————————–

    Apache Tomcat/7.0.54

    hi. i am geeting this error when i am running the project…what to do???

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>