Java – numberofviewsinsession and multiple tags

I have a big problem with my application and memory The application (Java with JSF / RichFaces / facelet) is used by about 7000 users at the same time

By default, the variable com sun. faces. Numberofviewsinsession is on the web Set in XML to 15 This variable creates a view tree that JSF retrieves when clicked back 15 times

For example, I have 3 screens for applications, and I use Firefox I enter the third screen in the first tab In the second tab, I have the first screen, and then click the next button, JSF retrieves the first screen and goes to the second screen

This mechanism is great, but it consumes a lot of memory (for me, the session needs 25mo). When you multiply this number by 7000, I need 175 go of memory, which is impossible

So I tried to set up com sun. faces. Numberofviewsinsession equals 1 (3Mo by session)

But in my example, when I click the second tab of the next button, I get the next error:

javax.servlet.ServletException: viewId:/private/pages/data/dataView.faces - View /private/pages/data/dataView.faces Could not be restored.
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at fr.generali.mezzo.front.commun.performance.filters.PerformanceFilter.doFilter(PerformanceFilter.java:72)
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:173)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
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:241)
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:447)
at java.lang.Thread.run(Thread.java:595)

This error is logical because my numberofviewsinsession is 1

So my question is:

Since I know the data in the view (for the second tab), how can I catch exceptions and create a new view for my users?

Thanks for your help.

Solution

Restoring views manually by leveraging your application specific knowledge may not be a task for timid people

If you want to follow this path, I think you should not try to catch exceptions, but use the statemanager API in JSF This allows you to customize the way the JSF framework manages its view state

Please note that this is an advanced topic Or in ED Burns' (JSF spec lead):

That is, if you haven't used JSF 2.0 yet, I strongly recommend upgrading to this An important new feature in JSF 2.0 is partial state saving This greatly reduces the amount of memory required to store the state

There is another option, I think you may have considered seeing you on COM sun. faces. Numberofviewsinsession and other parameters are used on the client This stores the view state in hidden fields and basically gives you unlimited memory because the client is used as distributed memory Of course, this will increase network overhead In the case of Ajax, this overhead can be too large to consider

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>