Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

JSTL Function in JSF 2.2 Composite functions only work properly if included in parent page #4226

Open
javaserverfaces opened this issue Jan 21, 2017 · 5 comments

Comments

@javaserverfaces
Copy link
Collaborator

Hi,

While testing some on the process of upgrading from JEE 6 to JEE 7, I encountered a fn:replace function cannot be found by the EL evaluation error.

Originally, I was under the impression the error would be caused by the taglib namespace for /functions having been changed in JSTL 1.2.

In the end I came to realize the problem seems to be in JSF 2.2.12 implementation in regard to coposite componets.

This issue bares resemblance to the:
https://java.net/jira/browse/JAVASERVERFACES-3469

But in this case we are not speaking about an EL that cannot be evaluated in inline.

In this case the EL is not working a component attribute.

The error is reproducible, and you can git clone the following repository to validate it:
https://github.com/99sono/jsf-2-2-fn-replace-not-found-bug/blob/master/README.md

The fn:replace exception seems to haven whenever the page that includes the composite component does not itself delare the xlmsns:fn namespace.

So the sample application shows you two pages.
The index.xhtml page can properly use fn:replace because it itself includes xlmns:fn.

The page that does not inclided xlmns:fn on the other hand, will see the composite component break apart with the following stack trace.

javax.el.ELException: Function 'fn:replace' not found
at com.sun.el.lang.ExpressionBuilder.visit(ExpressionBuilder.java:275)
at com.sun.el.parser.SimpleNode.accept(SimpleNode.java:172)
at com.sun.el.lang.ExpressionBuilder.prepare(ExpressionBuilder.java:227)
at com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:238)
at com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:295)
at com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:112)
at org.jboss.weld.util.el.ForwardingExpressionFactory.createValueExpression(ForwardingExpressionFactory.java:53)
at org.jboss.weld.el.WeldExpressionFactory.createValueExpression(WeldExpressionFactory.java:48)
at org.jboss.weld.util.el.ForwardingExpressionFactory.createValueExpression(ForwardingExpressionFactory.java:53)
at org.jboss.weld.el.WeldExpressionFactory.createValueExpression(WeldExpressionFactory.java:48)
at com.sun.faces.facelets.el.ELText$ELTextVariable.apply(ELText.java:211)
at com.sun.faces.facelets.el.ELText$ELTextComposite.apply(ELText.java:188)
at com.sun.faces.facelets.compiler.CommentInstruction.apply(CommentInstruction.java:81)
at com.sun.faces.facelets.compiler.UIInstructionHandler.apply(UIInstructionHandler.java:142)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:1006)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:651)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)

Many thanks for taking a lool.
There is a work-around for this issue, which is to have the fn:rpelace declared on the parent page.
However, the issue I believe is still quite major, because it costs people a lot of itme investigating why it was happening.

I was dumping the classpath to be sure that I could find:
wlserver/modules/org.glassfish.web.javax.servlet.jsp.jstl.jar!/org/apache/taglibs/standard/functions/Functions.class
As well as the tld file.

So this is an non-obvious issue to fix, when it happens.

Many thanks for taking a lool.
Kind regards.

Environment

Weblogic 12.2.1.2

Affected Versions

[2.2.12]

@javaserverfaces
Copy link
Collaborator Author

Reported by sono99

@javaserverfaces
Copy link
Collaborator Author

sono99 said:
The issue is in fact worse than above.
The work-around that saves the day in the sample application is of no use in the application that is experiencing the above problem.
Most likely because the application that is experiencing the problem is using rather more complex structure, with ui:compositation and parent template pages.

Even if all declare the xmlns:fn="http://java.sun.com/jsp/jstl/functions" namespace.
This makes no difference.

The fn:replace will work fine withing the : <ui:composition template elements but it will not work in the composite components.

I am now going to see if I can work-around this, by redeclaring the JSTL functions as faces-config.xml functions under a different namepsace.

... Let's see if take a rabbit out of the hat or come out empty handed.

@javaserverfaces
Copy link
Collaborator Author

sono99 said:
In fact i was wrong.
There as a combination of the two JSF - JSTL bugs.

(a) The need to redeclare the fn:function, as demonstrated in the sample application.

(b) Some javascipt with fn:replace inlined, that needed to be recomputed to ui:param.
As described in: #3473

@javaserverfaces
Copy link
Collaborator Author

This issue was imported from java.net JIRA JAVASERVERFACES-4222

@edburns
Copy link
Member

edburns commented Oct 29, 2017

Please see this important message regarding community contributions to
Mojarra.

https://javaee.groups.io/g/jsf-spec/message/30

Also, please consider joining that group, as that group has taken the
place of the old [email protected] mailing list.

Thanks,

Ed Burns

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

No branches or pull requests

3 participants