You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tiles.apache.org by Saminda Abeyruwan <sa...@gmail.com> on 2008/02/20 17:23:41 UTC
Bug in resolving locale
Hi Devs,
I'm using Tiles2 2.0.5 on top of an environment written in Embedded Tomcat
5.5.15.
I've a layout exactly as the samples are showing and in my index.jsp, i did
the following,
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="main.layout" />
which leads to following exception.
==================================================
ERROR [2008-02-20 20:44:20,564] Error executing tag: I/O error processing
configuration.
org.apache.tiles.definition.DefinitionsFactoryException: I/O error
processing configuration.
at org.apache.tiles.definition.UrlDefinitionsFactory.addDefinitions(
UrlDefinitionsFactory.java:256)
at org.apache.tiles.definition.UrlDefinitionsFactory.getDefinition(
UrlDefinitionsFactory.java:167)
at org.apache.tiles.impl.BasicTilesContainer.getDefinition(
BasicTilesContainer.java:513)
at org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:387)
at org.apache.tiles.impl.BasicTilesContainer.render(
BasicTilesContainer.java:370)
at org.apache.tiles.jsp.taglib.InsertDefinitionTag.render(
InsertDefinitionTag.java:63)
at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(
RenderTagSupport.java:171)
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.main_jsp._jspx_meth_tiles_insertDefinition_0(
org.apache.jsp.main_jsp:82)
at org.apache.jsp.main_jsp._jspService(org.apache.jsp.main_jsp:53)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java
:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(
JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
===========================================
When I debug the code, following problems are found in
org.apache.tiles.definition.UrlDefinitionsFactory
[1]. Go to line 165, if (!isContextProcessed(tilesContext)) {...
This line check if the locales are resolved. At the initial loading
locales are not processed.
[2]. Thus, this will execute the line 167, addDefinitions(definitions,
tilesContext), where the top part will add the locale to processedLocales
List.
[3]. After that it will load the "sources". Each will create an URL newUrl =
new URL(newPath); and loads. This sources are simply tiles_defs.xml s that
I've listed in the web.xml.
[4]. When I debug more I found out that "newPath" contains a URL as for
example, "jndi:/localhost/WEB-INF/tiles_defs.xml". When protocols like jndi
is used, URL object should be given with a URLStreamHandler. This caused the
above exception.
So the above "jndi" cause the problem. At the moment I've written a
URLStreamHandler and tweak the 2.0.5 code to fix the bug.
I would love to send a patch for this. But due to my lack of experience
with Tiles 2 code, my tweak wouldn't be the optimum solution. Shall I create
a JIRA for this issue.
Thank you
Saminda
--
Saminda Abeyruwan
Senior Software Engineer
WSO2 Inc. - www.wso2.org
Re: Bug in resolving locale
Posted by Antonio Petrelli <an...@gmail.com>.
2008/2/20, Saminda Abeyruwan <sa...@gmail.com>:
> https://issues.apache.org/struts/browse/TILES-254
Please attach a patch to this issue if you want to make it fixed faster.
> Is there any particular reason to re-load Definitions for the very first
> request, [UrlDefinitionsFactory line 167]. Since I'm not applying any filter
> at all, reloading defs for the very first request is very expensive.
Yes, and no. The reason why definitions loading for locale-related
definitions happens at the very first request is that we don't know if
there are "tiles-defs_XX.xml" files, until we try them when requested.
The problem we (committers) do not know how to list all the
"tiles-defs_*.xml" files, at least not in a portable manner.
> In order to not to make the initial request take a lot of time to process
> the already processed defs (which is already processed in deployment time),
> now I've commented out everything after line 227 to 271. Still it works and
> all the test passes.
I see: you are in a particular (not default, just like mine ;-) )
locale and you see the same definitions parsed twice, right?
Well, the reason is that for locale-specific definitions, the double
parsing seemed the best solution. The other solution would be to store
the "unresolved" (i.e. without calling the "resolveInheritance"
methods in DefinitionsImpl) definitions. But that means more memory to
use for all the time of the webapp running, and only for a limited
number of requests. If you find a better solution please let us know
:-)
Ciao
Antonio
Re: Bug in resolving locale
Posted by Saminda Abeyruwan <sa...@gmail.com>.
https://issues.apache.org/struts/browse/TILES-254
Is there any particular reason to re-load Definitions for the very first
request, [UrlDefinitionsFactory line 167]. Since I'm not applying any filter
at all, reloading defs for the very first request is very expensive.
In order to not to make the initial request take a lot of time to process
the already processed defs (which is already processed in deployment time),
now I've commented out everything after line 227 to 271. Still it works and
all the test passes.
Thank you
Saminda
On Feb 20, 2008 10:00 PM, Antonio Petrelli <an...@gmail.com>
wrote:
> 2008/2/20, Saminda Abeyruwan <sa...@gmail.com>:
> >
> > I would love to send a patch for this. But due to my lack of experience
> > with Tiles 2 code, my tweak wouldn't be the optimum solution.
>
>
>
> Don't worry about the "optimum" solution: if it is a bug, it must be
> corrected. Eventually we will discuss how to improve the solution :-)
>
>
> Shall I create
> > a JIRA for this issue.
>
>
>
> Yes, thanks.
>
> Ciao
> Antonio
>
--
Saminda Abeyruwan
Senior Software Engineer
WSO2 Inc. - www.wso2.org
Re: Bug in resolving locale
Posted by Antonio Petrelli <an...@gmail.com>.
2008/2/20, Saminda Abeyruwan <sa...@gmail.com>:
>
> I would love to send a patch for this. But due to my lack of experience
> with Tiles 2 code, my tweak wouldn't be the optimum solution.
Don't worry about the "optimum" solution: if it is a bug, it must be
corrected. Eventually we will discuss how to improve the solution :-)
Shall I create
> a JIRA for this issue.
Yes, thanks.
Ciao
Antonio