Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Problem while Struts 2 and Tiles 2 integration.

Abhijeet Kahale

2007-02-11

Replies:

Hi All,

I have created a small application to get familiar with the Struts 2 and
Tiles 2 integration.

I am using *struts2-tiles-plugin-2.0.5.jar* , *
tiles-api-2.0-20070130.184344-3.jar* and *
tiles-core-2.0-20070130.184344-3.jar* for the integration. (but the struts
core jar I am using is *struts2-core-2.0.1.jar *)
The dtd i used is http://jakarta.apache.org/struts/dtds/tiles-config_2_0.dtd
I have configured some actions and jsps to use Struts2 APIs and struts/tiles
tags
I am using Tomcat 5 as a web server.

When I start the tomcat, the application loads properly and no error is
thrown while bootstrap.
I even can load my first page which is a simple login page. But when I enter
something and login, I get following exception about the *tiles definition*

*<Exception>*
 *Messages*: I/O Error reading definitions. *File*:
org/apache/tiles/definition/digester/DigesterDefinitionsReader.java *Line
number*: 164
Stacktraces
org.apache.tiles.definition.DefinitionsFactoryException: I/O Error reading
definitions.
  org.apache.tiles.definition.digester.DigesterDefinitionsReader.read(
DigesterDefinitionsReader.java:164)
  org.apache.tiles.definition.UrlDefinitionsFactory.readDefinitions(
UrlDefinitionsFactory.java:257)

org.apache.tiles.definition.UrlDefinitionsFactory.getComponentDefinitions(
UrlDefinitionsFactory.java:116)
  org.apache.tiles.definition.UrlDefinitionsFactory.getDefinition(
UrlDefinitionsFactory.java:136)
  org.apache.tiles.impl.BasicTilesContainer.getDefinition (
BasicTilesContainer.java:434)
  org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:333)
  org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:315)
  org.apache.struts2.views.tiles.TilesResult.doExecute (TilesResult.java
:104)
  org.apache.struts2.dispatcher.StrutsResultSupport.execute(
StrutsResultSupport.java:175)
*</Exception>*

The snippet of my tiles-def file is
*<snip>*
<tiles-definitions>
  <definition name="blank" template="/pages/blank.jsp"/> *<!-- Formerly i
tried using "path" attribute also -->*
  <definition name=" earray.masterContent"
template="/pages/MasterWindow.jsp">
    <put name="titlebar" value="/pages/title.jsp"/>
    <put name="header" value="/pages/header.jsp"/>
    <put name="menubar" value="biochipMenu"/>
    <put name="upperbody" value="blank"/>
    <put name="divider" value="blank"/>
    <put name="lowerbody" value="blank"/>
    <put name="footer" value="blank"/>
  </definition>
  <definition name="earray.homepage" extends="earray.masterContent">
    <put name="upperbody" value="/pages/homePage.jsp"/>
  </definition>
</tiles-definitions>
*</snip>*
And the snipped from my struts.xml is.
*<snip>*
<struts>
  <package name="" namespace="/" extends="struts-default">
    <result-types>
       <result-type name="tiles" class="
org.apache.struts2.views.tiles.TilesResult"/>
    </result-types>
    <action name="Login" class="sample.Login">
       <result type="redirect">topMenu.action</result>
    </action>
    <action name="landingPage" class=" sample.Login" method="show">
       <result>/pages/login.jsp</result>
    </action>
    <action name="topMenu" class="sample.topmostMenu" >
       <result type="tiles">earray.homepage</result>
    </action>
  </package >
</struts>
*</snip>*
I even configured the *org.apache.struts2.tiles.StrutsTilesListener* in the
web.xml
Can anybody help me out?

One more thing I want to know is which tiles taglib should i use? First i
used the one which I used for struts 1-tiles 1 integration. Then I tried
without specifying any tld configuration in web.xml at all. (becoz in the
examples i searched, i didnt find anyone specifying it.)

Thanks an Regards,
Abhijeet.
©2008 junlu.com - Jax Systems, LLC, U.S.A.