4.0.5 <ui:composition template="path/to.xhtml"> broken with contracts?
Closed this issue · 1 comments
Describe the bug
ui:composition with a template from contracts bath does not work with mojarra 4.0.5
Probably caused by #5330
To Reproduce
We have a place similar to this tutorial:
https://javaee.github.io/tutorial/jsf-facelets008.html#:~:text=Resource%20library%20contracts%20allow%20you,section%20of%20your%20web%20application.
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets" template="/template.xhtml" />
with a faces-config.xml
<faces-config>
<application>
<resource-library-contracts>
<contract-mapping>
<url-pattern>*</url-pattern>
<contracts>default</contracts>
</contract-mapping>
</resource-library-contracts>
</application>
</faces-config>
Now when I debug I see that template.xhtml is resolved into: file:/C:/../testContractMappings/webapp/contracts/default/template.xhtml which is correct.
but because isContractsResource is true, which is also correct for that path, I will get "IOException: Contract resources cannot be accessed this way" from DefaultFacelet.
Caused by: jakarta.faces.view.facelets.TagAttributeException: /test.xhtml @2,96 <ui:composition template="template.xhtml"> Invalid path : template.xhtml
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:134)
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:52)
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:46)
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:132)
at jakarta.faces.impl@4.0.5//com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:331)
at jakarta.faces.impl@4.0.5//com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:70)
at jakarta.faces.impl@4.0.5//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:72)
at jakarta.faces.impl@4.0.5//com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:150)
at jakarta.faces.impl@4.0.5//jakarta.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:692)
... 45 more
Caused by: java.io.IOException: Contract resources cannot be accessed this way
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:298)
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:154)
at jakarta.faces.impl@4.0.5//com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:129)
... 53 more
Now after the change, can't ui:composition be used with contract-mapping-s any more or maybe I must change something in the mapping to use it in a different way or must do something to get it working with contracts again? We have not set jakarta.faces.WEBAPP_CONTRACTS_DIRECTORY.
Desktop (please complete the following information):
- OS: Windows/unix/mac
- Version 4.0.5
Additional context
I found this from Wildfly 31 and latest glassfish 7 that already use mojarra 4.0.5
Probably caused by #5330
Thanks for reporting. This is a bug. That use case was just overlooked and not covered by the TCK.