Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES-2535
Type: Bug Bug
Status: Closed Closed
Resolution: Invalid
Priority: Blocker Blocker
Assignee: Manfred Riem
Reporter: crcerror
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
javaserverfaces

UIComponent not thread safe use of facescontext Attributes

Created: 10/Oct/12 05:49 PM   Updated: 19/Oct/12 05:00 PM   Resolved: 19/Oct/12 05:00 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Duplicate
 

Tags:
Participants: crcerror, Ed Burns and Manfred Riem


 Description  « Hide

When using @viewScoped beans, if a user post multiple simultaneous requests to the bean there are multiple threads working on the same managed bean.
This causes an issue with the UIComponent class, there in the popComponentFromEL method is an unsafe get() call to a hashmap.

When the server is under a heavy load then some threads get stuck in an infinite loop in the get() method of the Hashmap implementation.

Is this a bug or it is a design choice not to synchronize the access to the contextAttributes hashmap?

details:
Weblogic 10.3.4
Jsf 2.0.6
jvm Oracle JRockit(R) R28.1.0-123-138454-1.6.0_20-20101014-1350-linux-x86_64

– problem method in UIComponent.class ----

private static ComponentStack _getComponentELStack(String keyName, Map<Object, Object> contextAttributes)
{
ComponentStack elStack = (ComponentStack)contextAttributes.get(keyName); <-- unsafe hashmap access, need to synchronize access?

if (elStack == null)

{ elStack = new ComponentStack(); contextAttributes.put(keyName, elStack); }

return elStack;
}

------- stack dump of stuck thread -----

"[STUCK] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" id=26 idx=0x7c tid=18549 prio=1 alive, native_blocked, daemon

at javax/faces/component/UIComponent.popComponentFromEL(UIComponent.java:1821)[optimized]

at javax/faces/component/UIComponent.popComponentFromEL(UIComponent.java:1846)[inlined]

at javax/faces/component/UIComponentBase.encodeEnd(UIComponentBase.java:884)[optimized]

at com/sun/faces/renderkit/html_basic/HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:308)[inlined]

at com/sun/faces/renderkit/html_basic/GroupRenderer.encodeChildren(GroupRenderer.java:101)[optimized]

at javax/faces/component/UIComponentBase.encodeChildren(UIComponentBase.java:849)[optimized]

at javax/faces/component/UIComponent.encodeAll(UIComponent.java:1648)[optimized]

at com/sun/faces/renderkit/html_basic/CompositeRenderer.encodeChildren(CompositeRenderer.java:75)[optimized]

at javax/faces/component/UIComponentBase.encodeChildren(UIComponentBase.java:849)[optimized]

at com/sun/faces/renderkit/html_basic/HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)[inlined]

at com/sun/faces/renderkit/html_basic/GroupRenderer.encodeChildren(GroupRenderer.java:101)[optimized]

at javax/faces/component/UIComponentBase.encodeChildren(UIComponentBase.java:849)[optimized]

at com/sun/faces/renderkit/html_basic/HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)[inlined]

at com/sun/faces/renderkit/html_basic/GroupRenderer.encodeChildren(GroupRenderer.java:101)[optimized]

at javax/faces/component/UIComponentBase.encodeChildren(UIComponentBase.java:849)[optimized]

at javax/faces/component/UIComponent.encodeAll(UIComponent.java:1648)[optimized]

at javax/faces/render/Renderer.encodeChildren(Renderer.java:164)[optimized]

at javax/faces/component/UIComponentBase.encodeChildren(UIComponentBase.java:849)[optimized]

at javax/faces/component/UIComponent.encodeAll(UIComponent.java:1648)[optimized]

at javax/faces/component/UIComponent.encodeAll(UIComponent.java:1651)[optimized]

at javax/faces/component/UIComponent.encodeAll(UIComponent.java:1651)[optimized]

at com/sun/faces/application/view/FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:395)[optimized]

at com/sun/faces/application/view/MultiViewHandler.renderView(MultiViewHandler.java:127)[inlined]

at com/sun/faces/lifecycle/RenderResponsePhase.execute(RenderResponsePhase.java:117)[optimized]

at com/sun/faces/lifecycle/Phase.doPhase(Phase.java:97)[optimized]

at com/sun/faces/lifecycle/LifecycleImpl.render(LifecycleImpl.java:135)[optimized]

at javax/faces/webapp/FacesServlet.service(FacesServlet.java:309)[optimized]

at weblogic/servlet/internal/StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)[optimized]

at weblogic/servlet/internal/StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)[inlined]

at weblogic/servlet/internal/ServletStubImpl.execute(ServletStubImpl.java:300)[optimized]

at weblogic/servlet/internal/TailFilter.doFilter(TailFilter.java:26)[optimized]

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[optimized]

at org/primefaces/webapp/filter/FileUploadFilter.doFilter(FileUploadFilter.java:79)[optimized]

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[optimized]

at nl/sidn/web/support/em/EntityManagerFilter.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V(Unknown Source)

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)[optimized]

at org/springframework/security/intercept/web/FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)[inlined]

at org/springframework/security/intercept/web/FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/ui/ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)

at org/springframework/security/ui/SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/providers/anonymous/AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)[optimized]

at org/springframework/security/ui/SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/ui/logout/LogoutFilter.doFilterHttp(LogoutFilter.java:89)

at org/springframework/security/ui/SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/ui/preauth/AbstractPreAuthenticatedProcessingFilter.doFilterHttp(AbstractPreAuthenticatedProcessingFilter.java:69)[optimized]

at org/springframework/security/ui/SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/context/HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)[optimized]

at org/springframework/security/ui/SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)[optimized]

at org/springframework/security/util/FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)[optimized]

at org/springframework/security/util/FilterChainProxy.doFilter(FilterChainProxy.java:175)[optimized]

at org/springframework/web/filter/DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)[optimized]

at org/springframework/web/filter/DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[optimized]

at nl/sidn/web/security/xsrf/CSRFFilter.doFilter(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Ljavax/servlet/FilterChain;)V(Unknown Source)[optimized]

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[optimized]

at weblogic/servlet/internal/RequestEventsFilter.doFilter(RequestEventsFilter.java:27)[optimized]

at weblogic/servlet/internal/FilterChainImpl.doFilter(FilterChainImpl.java:56)[inlined]

at weblogic/servlet/internal/WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)[inlined]

at weblogic/servlet/internal/WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)[optimized]

at weblogic/security/acl/internal/AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)[optimized]

at weblogic/security/service/SecurityManager.runAs(SecurityManager.java:120)[inlined]

at weblogic/servlet/internal/WebAppServletContext.securedExecute(WebAppServletContext.java:2277)[inlined]

at weblogic/servlet/internal/WebAppServletContext.execute(WebAppServletContext.java:2183)[optimized]

at weblogic/servlet/internal/ServletRequestImpl.run(ServletRequestImpl.java:1454)[optimized]

at weblogic/work/ExecuteThread.execute(ExecuteThread.java:207)[optimized]

at weblogic/work/ExecuteThread.run(ExecuteThread.java:176)

at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)



Ed Burns added a comment - 10/Oct/12 06:03 PM

When you say "if a user post multiple simultaneous requests to the bean" do you mean that there are multiple browser window/tabs in play here?


crcerror added a comment - 10/Oct/12 06:13 PM

yes multiple tabs/windows or users who have created scripts which they use to send requests to the application and creating heavy load while doing so.

i am not sure if the above analysis is correct, the only thing a have is the thread dump. But it is a big problem for us because the code in UIComponent
freezes and never returns the running thread to the pool. This could bring down our server in severe cases.


Ed Burns added a comment - 10/Oct/12 06:15 PM

As a workaround, and to aid in problem determination, can you change from using @ViewScoped to @SessionScoped, just for the problem bean? If that causes the problem to no longer manifest, then we have a starting point for understanding what's going on?


crcerror added a comment - 19/Oct/12 04:52 PM

Hi Ed,

We found out what the problem was.
somehow we packaged two versions of jsf (2.0.4 and 2.0.6) with our EAR artifact.
When we removed version 2.0.4 the problem dissapeard.

you can close this issue now.

thanks for your help!


Manfred Riem added a comment - 19/Oct/12 04:59 PM

Closing as per submitter