10 Replies Latest reply on Jan 3, 2012 10:44 AM by rhusar

    Session serialization

    pgervaise

      Hello,

       

      Perhaps I miss something but I don't manage to use session serialization for webapps on redeploy.

       

      Each time I redeploy my war, all session data is cleared.

       

      How to have session data written to disk ?

       

      (with JBoss 7.1.0.CR1b Final / Standalone)

       

      Thanks.

        • 1. Re: Session serialization
          sfcoy

          I've only ever seen WebSphere behave like this.

           

          As far as I know there is no requirement for HTTP sessions to survive application restarts unless the application is running in a distributed environment.

          • 2. Re: Session serialization
            nickarls

            A re-deployment is a definitive user operation and I would not expect the data to survive, odds are great that the application has changed so that the data is no longer compatible anyways.

            • 3. Re: Session serialization
              pgervaise

              You're right ... I just see that the feature doest not exist in JBoss 5 nor JBoss 4.2.3

               

              BUT it exists in JBoss 4.0.3-SP1 (we run a couple of web sites with that version) and it's a great feature to hot deploy web sites with a lot of sessions without swaping them !

               

              Nicklas has right : re-deployment can change data model but can also just change content (web pages) or business logic. But if the deserialization failed, it's ok : all sessions are swapped (and by the way there is java property "serialVersionUID" to force deserialization failure).

               

              I wonder to know if it's possible, with JBoss 7, to access to the Session Manager in a ServerContextListener (for intercepting deploy/undeploy events) ?

              • 4. Re: Session serialization
                sfcoy

                Actually, it looks like all of the bits you need (as described in http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html) are there.

                 

                You just need to figure out how to configure it. I'll leave that as an exercise for the reader!

                 

                I have no idea how "supported" this will be though. I imagine that refererences to EJBs, etc could be somewhat problematical.

                • 5. Re: Session serialization
                  rhusar

                  @Stephen Oh please no! Forget about Tomcat, its JBoss Web . Things better be done the AS way.

                   

                  @Philippe just for clarification, you are talking about "session persistence" not (only) serialization. Session will get serialized even when they are transfered around the cluster but are not persistent.

                   

                  I tried a workaround, to start 2 nodes and have sessesion replicated to each node, then redeploy on only one node. This didnt work for me, I need to give a more though why it didnt work (otherwise redeployments in the cluster work okay of course, there used to be a problem AS7-2463 shouldnt be in CR1).

                   

                  Of course, you will have to check yourself that the sessions are binary compatible with a new version and then purge the sessions when you do change it. Also you cant really blame the standard behaviour as Nicklas explains it.

                   

                  Rado

                  • 6. Re: Session serialization
                    nickarls

                    Nicklas has right : re-deployment can change data model but can also just change content (web pages) or business logic. But if the deserialization failed, it's ok : all sessions are swapped (and by the way there is java property "serialVersionUID" to force deserialization failure).

                     

                    True, but in most cases I would like to start from a "clean slate" when redeploying and there are cases where continuing on the bad data would be a Bad Thing(tm) even if it worked (especially if defaulted)

                    • 7. Re: Session serialization
                      sfcoy

                      Radoslav Husar wrote:

                       

                      @Stephen Oh please no! Forget about Tomcat, its JBoss Web . Things better be done the AS way.

                      Of course they are. I only mentioned it because AFAIK JBossWeb is made from embedded Tomcat bits, and that link contained information on configuring its Persistent Manager Implementation.

                      • 8. Re: Session serialization
                        rhusar

                        @Phillipe, to answer the original question, you just need to configure the file-store to be persistent with something like this:

                         

                        <file-store preload="true" passivation="false" purge="false"/>

                         

                        As currently its configured to passivate only the evicted entries. (However, you might run into https://issues.jboss.org/browse/AS7-3167 which imho should be supported.)

                         

                        Rado

                        • 9. Re: Session serialization
                          pgervaise

                          Thank you for the answer. But I don't know where to add <file-store>

                           

                          I'm running JBoss width Standalone configuration, it should be under urn:jboss:domain:infinispan:1.1. Perhaps (in gray) :

                           

                          <subsystem xmlns="urn:jboss:domain:infinispan:1.1" default-cache-container="hibernate">

                               <cache-container name="web" default-cache="repl">

                                    <alias>standard-session-cache</alias>

                                    <replicated-cache name="repl" mode="ASYNC" batching="true">

                                         <file-store preload="true" passivation="false" purge="false"/>

                                    </replicated-cache>

                               </cache-container>

                               <cache-container name="hibernate" default-cache="local-query">

                               ...

                          </subsystem>

                           

                          But I found something by inspecting jbossweb source code :

                           

                          When JBoss is started with "-Dorg.apache.catalina.session.StandardManager.PATHNAME=sessions.ser" session persistence is working each time webapp is undeployed/deployed and the "sessions.ser" file is written on (for "session.war") :

                           

                          D:\Appli\jboss-as-7.1.0.CR1\standalone\tmp\work\jboss.web\default-host\session\sessions.ser

                          • 10. Re: Session serialization
                            rhusar

                            For <file-store/> look at default standalone-ha.xml profile.

                             

                            But if "-Dorg.apache.catalina.session.StandardManager.PATHNAME=sessions.ser" works than thats probaly really easier (though when you add clustering it wont be very compatible).

                             

                            HTH,

                            Rado