[
https://issues.apache.org/jira/browse/WW-4672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15399007#comment-15399007
]
Joonas Vali commented on WW-4672:
---------------------------------
I noticed that the
org.apache.struts2.tiles.StrutsWildcardServletApplicationContext has a
reference to servletContext, so there would be no problem to compose the
StrutsApplicationResource with relative paths from that class instead of URLs.
To be honest I don't really use struts nor tiles myself so my knowledge of the
whole framework and their relationship is rather shallow. But since I work on a
tool, that has to support it, I noticed that previous versions of that
PostfixedApplicationResource were mostly returning relative paths, now they are
suddenly coming up with absolutes due to this subclass and figured this is
unintended change.
That NPE is real however, once the
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO#CHECK_REFRESH_INIT_PARAMETER
is set to true. I understand that using the automatic scan of the tiles files
doesn't invalidate the use of this flag, does it?
> StrutsApplicationResource incompatible with superclass
> PostfixedApplicationResource
> -----------------------------------------------------------------------------------
>
> Key: WW-4672
> URL: https://issues.apache.org/jira/browse/WW-4672
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Tiles
> Affects Versions: 2.5.2
> Reporter: Joonas Vali
> Priority: Minor
>
> {{org.apache.struts2.tiles.StrutsApplicationResource}} constructor takes in a
> single parameter, URL, and from this parameter getPath() is asked, which
> returns absolute path to a resource on disk (usually?), and this is passed to
> the superclass as String.
> This logic is however incompatible with superclass
> {{org.apache.tiles.request.locale.PostfixedApplicationResource}} which is
> built to deal with relative paths to the context root. e.g
> '/WEB-INF/tiles.xml'.
> Previous creates issues with 'refreshing' enabled in
> (CachingLocaleUrlDefinitionDAO) superclass
> {{org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO#refreshRequired()}}
> method, which iterates over these resource paths and ultimately calls
> {{servletContext#getResource(path)}}, which always returns null on absolute
> paths. This results in the following NPE on next line where
> {{resource.getLastModified()}} is asked.
> {noformat}
> java.lang.NullPointerException
> at
> org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO.refreshRequired(BaseLocaleUrlDefinitionDAO.java:120)
> at
> org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinitions(CachingLocaleUrlDefinitionDAO.java:130)
> at
> org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:105)
> at
> org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:49)
> at
> org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory.getDefinition(UnresolvingLocaleDefinitionsFactory.java:89)
> at
> org.apache.tiles.impl.BasicTilesContainer.getDefinition(BasicTilesContainer.java:286)
> at
> org.apache.tiles.impl.BasicTilesContainer.isValidDefinition(BasicTilesContainer.java:273)
> at
> org.apache.tiles.TilesContainerWrapper.isValidDefinition(TilesContainerWrapper.java:88)
> at
> org.apache.tiles.impl.mgmt.CachingTilesContainer.isValidDefinition(CachingTilesContainer.java:100)
> at
> org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:139)
> at
> org.apache.struts2.result.StrutsResultSupport.execute(StrutsResultSupport.java:208)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)