开发者

JSF Custom EL function works only on the first load of the page

开发者 https://www.devze.com 2022-12-28 11:55 出处:网络
I created a ( JSP-based) custom EL function to use in the rendered tag. The function will return a boolean to decide if a page component needs to be rendered on a page or not.

I created a ( JSP-based) custom EL function to use in the rendered tag. The function will return a boolean to decide if a page component needs to be rendered on a page or not. I import it onto the jsp page using <%@ taglib uri = "/WEB-INF/mine.tld" prefix = "g" %>.

Everything works perfect on the first load of the jsp page. Once a button is clicked, the form submits and then I am getting errors like 'No ClassLoaders found for: the class which implements my EL function' and 'Function not found'. What is going on here? What will be a fix?


The class implementing the function (com.util.WebContextLoader) is included as a utility class in the war.

Below is the stack trace.

09:22:31,112 ERROR [STDERR] java.lang.ClassNotFoundException: No ClassLoaders found for: com.util.WebContextLoader
09:22:31,112 ERROR [STDERR]     at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
09:22:31,112 ERROR [STDERR]     at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
09:22:31,112 ERROR [STDERR]     at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
09:22:31,112 ERROR [STDERR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
09:22:31,112 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)
09:22:31,112 ERROR [STDERR]     at java.lang.Class.forName(Class.java:169)
09:22:31,112 ERROR [STDERR]     at org.apache.el.lang.FunctionMapperImpl$Function.getMethod(FunctionMapperImpl.java:147)
09:22:31,112 ERROR [STDERR]     at org.apache.el.lang.FunctionMapperImpl.resolveFunction(FunctionMapperImpl.java:53)
09:22:31,112 ERROR [STDERR]     at org.apache.el.parser.AstFunction.getValue(AstFunction.java:71)
09:22:31,112 ERROR [STDERR]     at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
09:22:31,112 ERROR [STDERR]     at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
09:22:31,112 ERROR [STDERR]     at javax.faces.component.UIComponentBase.isRendere开发者_C百科d(UIComponentBase.java:390)
09:22:31,112 ERROR [STDERR]     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1018)
09:22:31,112 ERROR [STDERR]     at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
09:22:31,112 ERROR [STDERR]     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
09:22:31,112 ERROR [STDERR]     at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:540)
09:22:31,112 ERROR [STDERR]     at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
09:22:31,112 ERROR [STDERR]     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
09:22:31,112 ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
09:22:31,112 ERROR [STDERR]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:22:31,112 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
09:22:31,112 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
09:22:31,112 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
09:22:31,112 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:420)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
09:22:31,112 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
09:22:31,112 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
09:22:31,112 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
09:22:31,112 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
09:22:31,112 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:619)


09:22:31,112 WARN  [lifecycle] org.apache.jasper.el.JspELException: /register.jsp(45,2) '#{g:displayPageComponent('registrationPage', 'regUnit')}' Function 'g:displayPageComponent' not found
javax.faces.FacesException: org.apache.jasper.el.JspELException: /register.jsp(45,2) '#{g:displayPageComponent('registrationPage', 'regUnit')}' Function 'g:displayPageComponent' not found
    at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:393)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1018)
    at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:540)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:420)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.jasper.el.JspELException: /register.jsp(45,2) '#{g:displayPageComponent('registrationPage', 'regUnit')}' Function 'g:displayPageComponent' not found
    at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:107)
    at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)
    ... 34 more


java.lang.ClassNotFoundException: No ClassLoaders found for: com.util.WebContextLoader

The function class has apparently a dependency called com.util.WebContextLoader which is not available in its direct classpath neighbourhood.

That this happens intermittently is a sign that the classpath is polluted with duplicate classes/libraries spreading over the classpath which got loaded by different classloaders. I'd start to cleanup the classpath. Get rid of all webapp-specific classes/libs in JRE/lib, JRE/lib/ext and server/lib.


I found the solution to this issue in these threads.

http://community.jboss.org/message/46380

http://community.jboss.org/message/46385

The solution is to drop jasper-el-6.0.18.jar in the war’s /web-inf/lib folder by adding the following dependency to the pom.

org.apache.tomcat jasper-el 6.0.18

This dependency will also include "el-api-6.0.18.jar" (see http://repo1.maven.org/maven2/org/apache/tomcat/jasper-el/6.0.18/jasper-el-6.0.18.pom), which we need to exclude.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号