本文介绍了卡在 UIComponent.popComponentFromEL 的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用 JSF 2.1 和 PrimeFaces.最近,由于一些线程卡住,观察到非常高的 CPU 利用率.所有卡住线程的卡住线程转储指向 javax.faces.component.UIComponent.popComponentFromEL,如下所示:

My application uses JSF 2.1 with PrimeFaces. Recently, very high CPU Utilization was observed because of some stuck threads. The stuck thread dump for all stuck threads pointed to javax.faces.component.UIComponent.popComponentFromEL like below:

javax.faces.component.UIComponent.popComponentFromEL(UIComponent.java:1934)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1633)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
org.primefaces.component.api.UIData.visitRows(UIData.java:741)
org.primefaces.component.api.UIData.visitTree(UIData.java:656)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
org.primefaces.component.accordionpanel.AccordionPanel.visitTree(AccordionPanel.java:371)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIForm.visitTree(UIForm.java:371)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
com.sun.faces.application.view.StateManagementStrategyImpl.findComponent(StateManagementStrategyImpl.java:440)
com.sun.faces.application.view.StateManagementStrategyImpl.restoreDynamicRemove(StateManagementStrategyImpl.java:412)
com.sun.faces.application.view.StateManagementStrategyImpl.restoreDynamicActions(StateManagementStrategyImpl.java:317)
com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:281)
com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:453)
com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:142)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
com.ultimatix.bgc.framework.GBGCSessionControllerFilter.doFilter(GBGCSessionControllerFilter.java:90)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
com.ultimatix.framework.jsf.util.ForcedLoginFilter.doFilter(ForcedLoginFilter.java:505)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
com.ultimatix.framework.jsf.util.IndexFilter.doFilter(IndexFilter.java:338)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
com.ultimatix.framework.jsf.util.SecurityInterceptor.doFilter(SecurityInterceptor.java:40)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
weblogic.work.ExecuteThread.run(ExecuteThread.java:176)

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

根据 Mojarra issue 2722 当您错误地将组件实例绑定到非请求范围但范围更广的托管 bean 的 bean 属性时,就会发生这种情况.

As per Mojarra issue 2722 this will happen when you incorrectly bind component instances to a bean property of a managed bean which is not request scoped, but in a broader scope.

<x:someComponent binding="#{viewOrSessionOrApplicationScopedBean.component}" />

相应地修复代码,使这永远不会发生.组件本质上是请求范围的,绝对不能在多个请求之间共享.另请参见 JSF 2.0 规范第 3.1 章.5:

Fix the code accordingly that this never happens. Components are inherently request scoped and may absolutely not be shared across multiple requests. See also JSF 2.0 specitication chapter 3.1.5:

...

组件绑定通常与通过 Managed 动态实例化的 JavaBeans 结合使用Bean 创建工具(参见第 5.8.1 节VariableResolver 和默认 VariableResolver").强烈建议应用程序开发人员将组件绑定表达式指向的托管 bean 放在请求"范围.这是因为将它放在会话或应用程序范围内需要线程安全,因为UIComponent 实例依赖于在单个线程内运行.也有潜在的负面影响在会话"范围内放置组件绑定时的内存管理.

Component bindings are often used in conjunction with JavaBeans that are dynamically instantiated via the ManagedBean Creation facility (see Section 5.8.1 "VariableResolver and the Default VariableResolver"). It is stronglyrecommend that application developers place managed beans that are pointed at by component binding expressions in"request" scope. This is because placing it in session or application scope would require thread-safety, sinceUIComponent instances depends on running inside of a single thread. There are also potentially negative impacts onmemory management when placing a component binding in "session" scope.

另见:

10-30 09:37