myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jay Sartoris (JIRA)" <>
Subject [jira] [Commented] (MYFACES-4175) template XHTML file fails to load when in /resources dir
Date Fri, 05 Jan 2018 20:01:00 GMT


Jay Sartoris commented on MYFACES-4175:

I've attached a new WAR file named JSFTestResourcesBasic.war.  This application is very basic.
 There are no beans involved.  It is simply showing a facelet (index.xhtml) that has a ui:composition
component that specifies the template file in the /resources/templates directory of the app.
 When you request localhost:8080/JSFTestResourcesBasic/index.jsf you will see it fails with
a FileNotFoundException on the /resources/templates/basicTemplate.xhtml file when using MyFaces
2.3.  I used the latest Snapshot available (dated January 5, 2018).  I also tested this with
Mojarra 2.3.3 and it works.  Both tests were using Tomcat as the app server.  

Unfortunately I am not familiar with adding MyFaces unit tests.  I feel that providing a simple
war would quickly help show this issue. 

> template XHTML file fails to load when in /resources dir
> --------------------------------------------------------
>                 Key: MYFACES-4175
>                 URL:
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.3.0-beta
>            Reporter: Jay Sartoris
>            Priority: Minor
>             Fix For: 2.3.0
>         Attachments: JSFTestResources.war, MYFACES-4175.patch
> Please consider the following scenario, I've attached a sample app. 
> I have a template in the resources/templates directory.  The request to localhost:8080/JSFTestResources/mapViewIdToResource.jsf
fails when MyFaces to load the basicTemplate.xhtml  file which is located in the /resources/templates
directory for the composite component.  The backing bean uses the ResourceHandler to create
the view resources.
> The reason this fails in JSF 2.3 is due to the change in the org.apache.myfaces.resource.RootExternalContextResourceLoader.getResourceURL(String)
> In JSF 2.3, the method added a check to see if the resourceId starts wiht the contractsDirectory
or resourcesDirectory.  If it does then the getResourceURL returns null which tells the ResourceLoader
that the resource does not exist.  In JSF 2.2, those checks were not there.
> I checked the change history for this class and I see that MYFACES-4105 added this change.
 In that JIRA I see the comment made that says:
> "One last review is required to check if xhtml files under forbidden extensions are being
loaded (/resources, /contracts and so on)."
> Therefore, this falls in to the JIRA comment mentioned above.  To me, the test I've attached
seems to be a valid scenario and MyFaces should be allowing this resource to be found instead
of returning null.  I don't see anywhere in the spec that says MyFaces should be behaving
in that manner. Please correct me if I'm wrong.
> Also, this app works with MyFaces JSF 2.2 and also with Mojarra JSF 2.3.  
> With MyFaces JSF 2.3 I get a NPE:
> java.lang.NullPointerException
> 	com.test.MapResourcePathBean.mapViewIdToResource(
> 	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	sun.reflect.NativeMethodAccessorImpl.invoke(
> 	sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	java.lang.reflect.Method.invoke(
> 	javax.el.BeanELResolver.invoke(
> 	javax.el.CompositeELResolver.invoke(
> 	org.apache.el.parser.AstValue.getValue(
> 	org.apache.el.ValueExpressionImpl.getValue(
> 	org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(

This message was sent by Atlassian JIRA

View raw message