7 Replies Latest reply on Nov 14, 2008 5:39 AM by asrichas2can

    RichFaces and url rewriting: to many sessions?

    asrichas2can

      Because our user can use our application in to modes (edit and search) parallel, we had to switch from session cookies to url rewriting.

      With session cookies we had the problem that RichFaces seems to mix up the sessions although they are running on different ports.

      So we switched to url rewriting.
      That helped for this problem, but now we have a different one:
      Many empty sessions (hundereds!). We are using the push bean component, which seems to create new http requests without the url rewrite parameter attached.

      Any idea?

        • 1. Re: RichFaces and url rewriting: to many sessions?
          alexsmirnov

          RichFaces push component uses as short as possible 'HEAD' requests to check server data. These requests detected by the RichFaces filter and processes without session reference. It is required by the Servlet spec to not create session without request.
          There are some possible problems:
          1) Web server creates session without direct reference from application. What application server do you use ?
          2) You have some custom filter on front of the Richfaces filter, that creates session for an any requests. Try to change filters definition order in the web.xml ( move RichFaces filter mapping definition after all other ). It can aldo increase application performance.

          • 2. Re: RichFaces and url rewriting: to many sessions?
            asrichas2can

            We are using Tomcat 6.0.
            The filters we use are coming from Spring, a4j is already the last one.

            <filter>
             <filter-name>RequestContextFilter</filter-name>
             <filter-class>
             org.springframework.web.filter.RequestContextFilter
             </filter-class>
             </filter>
             <filter>
             <filter-name>Acegi Filter Chain Proxy</filter-name>
             <filter-class>
             org.acegisecurity.util.FilterToBeanProxy
             </filter-class>
             <init-param>
             <param-name>targetClass</param-name>
             <param-value>
             org.acegisecurity.util.FilterChainProxy
             </param-value>
             </init-param>
             </filter>
             <filter>
             <display-name>Ajax4jsf Filter</display-name>
             <filter-name>ajax4jsf</filter-name>
             <filter-class>org.ajax4jsf.Filter</filter-class>
             <init-param>
             <param-name>createTempFiles</param-name>
             <param-value>true</param-value>
             </init-param>
             <init-param>
             <param-name>maxRequestSize</param-name>
             <param-value>0</param-value>
             </init-param>
             </filter>
            


            • 3. Re: RichFaces and url rewriting: to many sessions?
              ilya_shaikovsky

               


              2) You have some custom filter on front of the Richfaces filter, that creates session for an any requests. Try to change filters definition order in the web.xml ( move RichFaces filter mapping definition after all other ). It can aldo increase application performance.


              As Alex mentioed - you have to defined RF filter the first in chain.

              • 4. Re: RichFaces and url rewriting: to many sessions?
                asrichas2can

                Thanks, but I don't understand:
                Alex said:

                move RichFaces filter mapping definition AFTER all other

                Ilya said:
                you have to defined RF filter the FIRST in chain.


                First or last?
                Or are the last filter entries the one which are used first?

                • 5. Re: RichFaces and url rewriting: to many sessions?
                  ilya_shaikovsky

                  seems Alex mistaken in word there.. There should be "move Before"

                  • 6. Re: RichFaces and url rewriting: to many sessions?
                    alexsmirnov

                    Filter definition order is not important, but mapping order is. It is defined by the <filter-mapping> element.
                    Sorry, i did mistake in the my answer: of course, first defined filter will be executed first.

                    • 7. Re: RichFaces and url rewriting: to many sessions?
                      asrichas2can

                      Thanks for the clarification.
                      It seems to help, now I have only 1-3 sessions per user - instead of hundreds. That should be OK for the server runtime.

                      Thanks for your help!