views:

224

answers:

2

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.isRendered(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
A: 

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.

BalusC
I changed javax.faces.STATE_SAVING_METHOD in web.xml to server from client and that solved my issue for now. I am not sure if I want to keep that setting in the long run (probably some performance impact?).
jsfQ
Interesting. All it basically does is storing the component tree in the client side instead of the server side. The component tree has still to be restored in the server side (the 1st phase of JSF lifecycle). I don't see how this resolves the classloading issue. Maybe there was more at matter which you accidently/unawarely solved as well at the same moment. Now it works, try setting it back to server and redeploy/restart and see if it still works.
BalusC
Many people have posted about this class loading issue with EL functions.https://jira.jboss.org/jira/browse/JBSEAM-1903
jsfQ
Looks like a JBoss issue. http://www.mailinglistarchive.com/[email protected]/msg03121.html
jsfQ
Nasty bug then.
BalusC
A: 

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.

jsfQ