Concurrent requests and Orchestra
Hi, we have a problem with concurrent request using combination Orchestra + Spring + Trinidad. The application uses more than one window per session, so we have migrated all our beans to orchestra's conversation scope using conversation.manual. We have a progress bar which is poling AJAX request during the main request is being done. Once user is waiting to the main request, there are partial requests each five seconds using Trinidad Javascript API. To be able handle more requests the partial request goes in another frame with same conversationContext. Both partial and full request are accessing to the same bean. And this is the problem because there is there is ReentrantLock used not to be able to access to FacesContex from different thread. So that means, that we are not able to access to the progressbar model and the partial request is locked till the full request is finished. But I haven't understood why there is this concurrent limitatins because they aren't in other scopes. This is the comment from the source code: // Fetch a context for this request if one already exists, and lock it 72 // so that concurrent requests that affect this context block until 73 // this request is complete. Not doing so can cause races for resources 74 // within the current context, such as beans or PersistenceContexts. But what kind of races and why there are not same problems using other scopes. Can anybody explain me the reasons please? Is there any possibility how to make a workaround? Thanks Daemon Thread [http-8080-1] (Suspended) Object.wait(long) line: not available [native method] [local variables unavailable] _ReentrantLock.lockInterruptibly() line: 80 ConversationContext.lockInterruptablyForCurrentThread() line: 475 ContextLockRequestHandler.init(FacesContext) line: 96 OrchestraFacesContextFactory$1.init(OrchestraFacesContextFactory, FacesContext, boolean, LinkedList, FacesContext) line: 119 OrchestraFacesContextFactory.getFacesContext(Object, Object, Object, Lifecycle) line: 100 RequestParameterFacesContextFactory.getFacesContext(Object, Object, Object, Lifecycle) line: 92 FacesContextFactoryImpl.getFacesContext(Object, Object, Object, Lifecycle) line: 64 FacesServlet.service(ServletRequest, ServletResponse) line: 260 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 290 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 TrinidadFilterImpl._invokeDoFilter(ServletRequest, ServletResponse, FilterChain) line: 238 TrinidadFilterImpl._doFilterImpl(ServletRequest, ServletResponse, FilterChain) line: 195 TrinidadFilterImpl.doFilter(ServletRequest, ServletResponse, FilterChain) line: 138 TrinidadFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 92 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 LicenseFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 123 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 ResponseHeaderFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 54 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 SessionTimeoutFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 116 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 StandardWrapperValve.invoke(Request, Response) line: 233 StandardContextValve.invoke(Request, Response) line: 175 StandardHostValve.invoke(Request, Response) line: 128 ErrorReportValve.invoke(Request, Response) line: 102 StandardEngineValve.invoke(Request, Response) line: 109 CoyoteAdapter.service(Request, Response) line: 263 Http11Processor.process(Socket) line: 844 Http11Protocol$Http11ConnectionHandler.process(Socket) line: 584 JIoEndpoint$Worker.run() line: 447 Thread.run() line: 619
RE: Concurrent requests and Orchestra
Hi! A PersistenceContext is not thread safe, therefore, Orchestra tries to avoid that by locking the request. It would be nice, if Orchestra does this just for requests requireing a PersistenceContext. But till today, we did not manage to spend some time to optimize that code. You can set the webapp init parameter org.apache.myfaces.orchestra.CoreConfig:SERIALIZE_REQUESTS to false so that Orchestra does not check for thread safety. You then have to ensure threadsafety against the PersistenceContext yourself (which might not be easy … not to say, impossible :-( ) Ciao, Mario Von: vojtech.zav...@gmail.com [mailto:vojtech.zav...@gmail.com] Im Auftrag von Vojtech Zavrel Gesendet: Donnerstag, 20. August 2009 10:51 An: users@myfaces.apache.org Betreff: Concurrent requests and Orchestra Hi, we have a problem with concurrent request using combination Orchestra + Spring + Trinidad. The application uses more than one window per session, so we have migrated all our beans to orchestra's conversation scope using conversation.manual. We have a progress bar which is poling AJAX request during the main request is being done. Once user is waiting to the main request, there are partial requests each five seconds using Trinidad Javascript API. To be able handle more requests the partial request goes in another frame with same conversationContext. Both partial and full request are accessing to the same bean. And this is the problem because there is there is ReentrantLock used not to be able to access to FacesContex from different thread. So that means, that we are not able to access to the progressbar model and the partial request is locked till the full request is finished. But I haven't understood why there is this concurrent limitatins because they aren't in other scopes. This is the comment from the source code: // Fetch a context for this request if one already exists, and lock it 72 // so that concurrent requests that affect this context block until 73 // this request is complete. Not doing so can cause races for resources 74 // within the current context, such as beans or PersistenceContexts. But what kind of races and why there are not same problems using other scopes. Can anybody explain me the reasons please? Is there any possibility how to make a workaround? Thanks Daemon Thread [http-8080-1] (Suspended) Object.wait(long) line: not available [native method] [local variables unavailable] _ReentrantLock.lockInterruptibly() line: 80 ConversationContext.lockInterruptablyForCurrentThread() line: 475 ContextLockRequestHandler.init(FacesContext) line: 96 OrchestraFacesContextFactory$1.init(OrchestraFacesContextFactory, FacesContext, boolean, LinkedList, FacesContext) line: 119 OrchestraFacesContextFactory.getFacesContext(Object, Object, Object, Lifecycle) line: 100 RequestParameterFacesContextFactory.getFacesContext(Object, Object, Object, Lifecycle) line: 92 FacesContextFactoryImpl.getFacesContext(Object, Object, Object, Lifecycle) line: 64 FacesServlet.service(ServletRequest, ServletResponse) line: 260 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 290 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 TrinidadFilterImpl._invokeDoFilter(ServletRequest, ServletResponse, FilterChain) line: 238 TrinidadFilterImpl._doFilterImpl(ServletRequest, ServletResponse, FilterChain) line: 195 TrinidadFilterImpl.doFilter(ServletRequest, ServletResponse, FilterChain) line: 138 TrinidadFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 92 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 LicenseFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 123 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 ResponseHeaderFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 54 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 SessionTimeoutFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 116 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 StandardWrapperValve.invoke(Request, Response) line: 233 StandardContextValve.invoke(Request, Response) line: 175 StandardHostValve.invoke(Request, Response) line: 128 ErrorReportValve.invoke(Request, Response) line: 102 StandardEngineValve.invoke(Request, Response) line: 109 CoyoteAdapter.service(Request, Response) line: 263 Http11Processor.process(Socket) line: 844 Http11Protocol$Http11ConnectionHandler.process(Socket) line: 584 JIoEndpoint$Worker.run() line: 447 Thread.run() line: 619
how to read data from the request after session timeout?
Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputTextvalue=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }
Re: how to read data from the request after session timeout?
FacesContext.getExternalContext().getRequest should point you towards the servlet request. Werner Georg Füchsle schrieb: Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }
Re: how to read data from the request after session timeout?
Hallo Werner, I have got the request as a variable. Now I want to read from it the state of the hidden input-field, that was on the jsf-Page. This is the input-field: t:inputTextvalue=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ How can I read its value from the request? Thanks, Georg 2009/8/20 Werner Punz werner.p...@gmail.com: FacesContext.getExternalContext().getRequest should point you towards the servlet request. Werner Georg Füchsle schrieb: Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }
Re: how to read data from the request after session timeout?
via getParameter, just the usual servlet way, have in mind that you have to use the clientId, the in html displayed id of the input field. JSF does an internal id mapping so the id loginType might be mapped to a value along the lines of viewId:formId:loginType Georg Füchsle schrieb: Hallo Werner, I have got the request as a variable. Now I want to read from it the state of the hidden input-field, that was on the jsf-Page. This is the input-field: t:inputTextvalue=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ How can I read its value from the request? Thanks, Georg 2009/8/20 Werner Punz werner.p...@gmail.com: FacesContext.getExternalContext().getRequest should point you towards the servlet request. Werner Georg Füchsle schrieb: Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }
Re: how to read data from the request after session timeout?
Hallo Werner, that was what I was looking for! Thanks for your fast and excellent help! Cheers Georg 2009/8/20 Werner Punz werner.p...@gmail.com: via getParameter, just the usual servlet way, have in mind that you have to use the clientId, the in html displayed id of the input field. JSF does an internal id mapping so the id loginType might be mapped to a value along the lines of viewId:formId:loginType Georg Füchsle schrieb: Hallo Werner, I have got the request as a variable. Now I want to read from it the state of the hidden input-field, that was on the jsf-Page. This is the input-field: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ How can I read its value from the request? Thanks, Georg 2009/8/20 Werner Punz werner.p...@gmail.com: FacesContext.getExternalContext().getRequest should point you towards the servlet request. Werner Georg Füchsle schrieb: Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }
Re: how to read data from the request after session timeout?
Glad I could help Werner Georg Füchsle schrieb: Hallo Werner, that was what I was looking for! Thanks for your fast and excellent help! Cheers Georg 2009/8/20 Werner Punz werner.p...@gmail.com: via getParameter, just the usual servlet way, have in mind that you have to use the clientId, the in html displayed id of the input field. JSF does an internal id mapping so the id loginType might be mapped to a value along the lines of viewId:formId:loginType Georg Füchsle schrieb: Hallo Werner, I have got the request as a variable. Now I want to read from it the state of the hidden input-field, that was on the jsf-Page. This is the input-field: t:inputTextvalue=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ How can I read its value from the request? Thanks, Georg 2009/8/20 Werner Punz werner.p...@gmail.com: FacesContext.getExternalContext().getRequest should point you towards the servlet request. Werner Georg Füchsle schrieb: Hallo all, when a session of an user timed out I display a Website telling 'Your Session expired; please login again!. Now I have to distinguish some 'loginType' of the user. If the user initially logged on by ldap i have to redirect him to another site as if he logged in by internal mechanisms. So I have to access the user's logintype data after the session timed out. I was thinking on a solution without using cookies: To do so, I put the loginType data to a hidden input field on the website. I thought that this data is not lost doing a request after session timeout. Unfortunately at the restoreview-Phase the data was not already written to the bean. But I think: in the request there will be sent also the information from the old (session timed out) page. So I also should be able to read the value of this input-field 'loginType'. Is there any possibility to read from the request? Can anybody tell me if I am right, and tell me how to read this data? I use JSF Tomahawk and Facelets. Thanks! Here my input-text: t:inputText value=#{mbUser.loginType} id=loginType immediate=true style=display:none;visibility:hidden;/ here my PhaseListener: class PhaseListener { public void beforePhase(PhaseEvent event) { if(event.getPhaseId() == PhaseId.RESTORE_VIEW) { /* before processing any request, I control if the User is logged in to the application: */ UserBean user = JsfUtils.getUserBean(); if(!user.loggedIn()) { /* User is not logged in! */ ExternalContext extCtx = event.getFacesContext().getExternalContext(); HttpServletRequest request = (HttpServletRequest) extCtx.getRequest(); String reqUri = request.getRequestURI(); if(startOrErrorPageIsCalled(reqUri)) { /* Users that are not logged in are only allowed to see the login-page or the error pages... */ return; } else { /* Users that is not logged in tried to request the application. I want to redirect him to a page 'sessionExpired' depending on his former loginType; this loginType I want to save on the website; */ // HERE THE LOGINTYPE WAS NOT reset to the Bean. is there any other possibility to read this value from the request? if(user.getLoginType() == 1) { event.getFacesContext().getExternalContext().redirect(JsfUtils.getKontextRoot() + sessionExpired.jsf); } else { // redirect him to another website } } } } } }