Details
Description
Tapestry's resource finder throws a StringIndexOutOfBoundsException when
an asset doesn't contains a "." (the search result of 'lastIndexOf' is -1).
The problem is in LocalizedContextResourceFinder.resolve(), and can be fixed by
adding the following avec «int dotx = context.path.lastIndexOf('.')» :
if (dotx < 0) {
return new LocalizedResource(contextPath, Locale.getDefault());
}
OR (at least) :
if (dotx < 0) {
throws new ApplicationRuntimeException("Asset has no extension: " +
contextPath);
}
it may also return null, tought. The main problem is that the error report
doesn't link the error with the component specification, but with the first
component who needs the problematic component.
Here the exact Tapestry's error page:
An exception has occurred.
You may continue by restarting the session.
org.apache.tapestry.ApplicationRuntimeException
Unable to instantiate component Home/$ShowError.$RoundedBorder: String index out
of range: -1
component:
com.alloa.tapestry.jwcs.RoundedBorder$Enhance_225@ba175f[Home/$ShowError.$RoundedBorder]
location: context:/WEB-INF/ShowError.html, line 3
java.lang.StringIndexOutOfBoundsException
String index out of range: -1
Stack Trace:
- java.lang.String.substring(String.java:1444)
*
org.apache.tapestry.util.LocalizedContextResourceFinder.resolve(LocalizedContextResourceFinder.java:57)
*
org.apache.tapestry.resource.ContextResourceLocation.getLocalization(ContextResourceLocation.java:71) - org.apache.tapestry.pageload.PageLoader.findAsset(PageLoader.java:935)
- org.apache.tapestry.pageload.PageLoader.convert(PageLoader.java:918)
- org.apache.tapestry.pageload.PageLoader.addAssets(PageLoader.java:838)
*
org.apache.tapestry.pageload.PageLoader.constructComponent(PageLoader.java:512)
*
org.apache.tapestry.pageload.PageLoader.createImplicitComponent(PageLoader.java:577)
*
org.apache.tapestry.BaseComponentTemplateLoader.createImplicitComponent(BaseComponentTemplateLoader.java:295)
*
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:237)
*
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:172) - org.apache.tapestry.BaseComponent.readTemplate(BaseComponent.java:100)
- org.apache.tapestry.BaseComponent.finishLoad(BaseComponent.java:135)
*
org.apache.tapestry.pageload.PageLoader.constructComponent(PageLoader.java:520)
*
org.apache.tapestry.pageload.PageLoader.createImplicitComponent(PageLoader.java:577)
*
org.apache.tapestry.BaseComponentTemplateLoader.createImplicitComponent(BaseComponentTemplateLoader.java:295)
*
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:237)
*
org.apache.tapestry.BaseComponentTemplateLoader.process(BaseComponentTemplateLoader.java:172) - org.apache.tapestry.BaseComponent.readTemplate(BaseComponent.java:100)
- org.apache.tapestry.BaseComponent.finishLoad(BaseComponent.java:135)
*
org.apache.tapestry.pageload.PageLoader.constructComponent(PageLoader.java:520) - org.apache.tapestry.pageload.PageLoader.loadPage(PageLoader.java:760)
- org.apache.tapestry.pageload.PageSource.getPage(PageSource.java:153)
- org.apache.tapestry.engine.RequestCycle.getPage(RequestCycle.java:196)
- org.apache.tapestry.engine.HomeService.service(HomeService.java:59)
- org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
- org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
- org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
...
Attachments
Attachments
1.
|
Fix for tapestry 4.0 | Resolved | Jesse Kuhnert |