Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.5 <ui:composition template="path/to.xhtml"> broken with contracts? #5389

Closed
andresluuk opened this issue Jan 29, 2024 · 1 comment
Closed
Milestone

Comments

@andresluuk
Copy link

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 [email protected]//com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:134)
        at [email protected]//com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:52)
        at [email protected]//com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:46)
        at [email protected]//com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:132)
        at [email protected]//com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:331)
        at [email protected]//com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:70)
        at [email protected]//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:72)
        at [email protected]//com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:150)
        at [email protected]//jakarta.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:692)
        ... 45 more
Caused by: java.io.IOException: Contract resources cannot be accessed this way
        at [email protected]//com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:298)
        at [email protected]//com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:154)
        at [email protected]//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

@BalusC
Copy link
Contributor

BalusC commented Jan 29, 2024

Thanks for reporting. This is a bug. That use case was just overlooked and not covered by the TCK.

BalusC added a commit that referenced this issue Feb 3, 2024
validated against the path of the facelet itself not against the
resolved url of the facelet
#5389
BalusC added a commit that referenced this issue Feb 3, 2024
…ng_base_url_to_validate_contracts_resource

#5389: Fix wrong base url to validate contracts resource
BalusC added a commit that referenced this issue Feb 10, 2024
@BalusC BalusC added this to the 4.0.6 milestone Feb 10, 2024
@BalusC BalusC closed this as completed Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants