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

Fixed jakarta.faces.WEBAPP_CONTRACTS_DIRECTORY spec/impl mismatch #5330

Merged
merged 2 commits into from
Oct 14, 2023

Conversation

BalusC
Copy link
Contributor

@BalusC BalusC commented Oct 8, 2023

Refactor retrieval and validation of webapp contracts directory into a single place and fixed a couple of misassumptions about it always being an absolute path.

#5329

single place and fixed a couple of misassumptions about it always being
an absolute path #5329
@BalusC BalusC added the 4.0 label Oct 8, 2023
@BalusC BalusC marked this pull request as ready for review October 8, 2023 16:07
@@ -127,16 +126,12 @@ public void apply(FaceletContext ctxObj, UIComponent parent) throws IOException
if (path.trim().length() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.isBlank()

Copy link
Contributor Author

@BalusC BalusC Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not part of fix, but indeed candidate to be improved project-wide in a new pr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because you were editing those files ... ;)

@@ -108,16 +107,12 @@ public void apply(FaceletContext ctxObj, UIComponent parent) throws IOException
if (path.trim().length() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.isBlank()

Copy link
Contributor Author

@BalusC BalusC Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not part of fix, but indeed candidate to be improved project-wide in a new pr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just because you were editing those files ... ;)

Copy link
Contributor

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BalusC BalusC merged commit c694635 into 4.0 Oct 14, 2023
2 checks passed
@BalusC BalusC deleted the mojarra_issue_5329_contracts_directory_impl_is_broken branch October 14, 2023 11:42
@arjantijms arjantijms added this to the 4.0.5 milestone Nov 13, 2023
@andresluuk
Copy link

andresluuk commented Jan 26, 2024

Maybe this one broke some logic or there is something I must change on using ui:composition now because of the contract change?
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>
    <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, 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 get it working with contracts again? We have not set jakarta.faces.WEBAPP_CONTRACTS_DIRECTORY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants