7 Replies Latest reply on Aug 26, 2009 5:30 PM by dthompsn

    Session persistence across multiple deploys

    dthompsn

      After about a month of hard study and developing sample applications our development group is starting to understand how to code some nice Seam applications. One of the things that we're experiencing and have found no documentation on is persistence of a War after a redeploy. We typically write applications where users login and perform actions and with our current framework, we are able to deploy these applications in the middle of the day since we have Tomcat set up to persist sessions. However, it appears that if we redeploy a Seam war, credentials, identities and conversations are lost. Is there something we're missing in a configuration file somewhere?


      I know I can hot deploy and not have this problem, but it appears that I can't do it on our production deploys that we don't hot deploy.

        • 1. Re: Session persistence across multiple deploys
          asookazian

          If you do not have a cluster (e.g. 2 node horz JBoss cluster) setup, then when you restart JBoss, everything in all scopes for all components are lost.  The one exception may be business process scope (which I do not have experience with), but I do know that it can outlive a server restart but that is b/c data is persisted to the db with jBPM integration, etc.


          bottom line: with no cluster and no persistence storage, all is lost on restart.


          This will be true with Spring/Hibernate/Tomcat w/o cluster as well.  Or any other JEE 5 certified app server.


          With a cluster, if you have state replication enabled, then even if a node goes down, there should be seamless failover (i.e. client doesn't know a node failed and they don't lose state in shopping cart bean, etc.) as state is typically replicated to another node (or nodes) synchronously or asynchronously when a business method completes successfully.

          • 2. Re: Session persistence across multiple deploys
            dthompsn

            This isn't true. If you set up jboss to persist between application restarts by setting the <Manager pathname=SESSIONS.ser /> within jboss-web.deployer/context.xml then things will persist across an ant deploy. This is what I have done. However, after further investigation what I have discovered is that if an EntityHome instance is created in a conversation and the coversation is active when the application is deployed (ant deploy), then an error happens when loading the EntityHome instances and all serialized objects are lost (becuase of the error), requiring users to log back in.


            I'm using JBoss 4.2.3, Seam 2.2 and projects deployed as WARs.


            The relavant parts of the error message are:


            [ManagerBase] ClassNotFoundException while loading persisted sessions: java.lang.ClassNotFoundException: No ClassLoaders found for: org.safmt.invmi.action.DummyHome
            java.lang.ClassNotFoundException: No ClassLoaders found for: org.safmt.invmi.action.DummyHome



            I know Seam 2.2 is targeting jboss 5.1 in terms of jboss, but I'm wondering what I might have to change (in terms of settings) to get this working on jboss 4.2.3.


            • 3. Re: Session persistence across multiple deploys
              dthompsn

              More information.


              I deployed to JBoss 5.1, set the Manager up for the tomcat session and am seeing the problem there as well.


              So working my way through this, I found that if my component extends Controller, PersistenceController, or MutableController things are fine. As soon as my component extends Home, then I get the problem. Making my own copy of home and playing with the object a lot, I finally figured out that the issue is with the @Scope() annotation. If I removed this annotation, then my component is Serializable again and things don't blow up.


              Any ideas? Am I way off base here?
              David

              • 4. Re: Session persistence across multiple deploys
                asookazian

                David Thompson wrote on Aug 25, 2009 17:16:


                This isn't true. If you set up jboss to persist between application restarts by setting the <Manager pathname=SESSIONS.ser /> within jboss-web.deployer/context.xml then things will persist across an ant deploy.


                <!-- The contents of this file will be loaded for each web application -->
                <Context cookies="true" crossContext="true">
                   <!-- Session persistence is disable by default. To enable for all web
                   apps set the pathname to a non-empty value:
                   <Manager pathname="SESSIONS.ser" />
                
                   To enable session persistence for a single web app, add a
                   WEB-INF/context.xml 
                   -->
                   <Manager pathname="" />
                
                   <!-- Install an InstanceListener to handle the establishment of the run-as
                   role for servlet init/destroy events.
                   -->
                   <InstanceListener>org.jboss.web.tomcat.security.RunAsListener</InstanceListener>
                   
                </Context>



                I was unaware of this file but do not know if it's best practice to serialize session state to disk on every deployment.

                • 5. Re: Session persistence across multiple deploys
                  dthompsn

                  Even more info:


                  If I change the @Scope on the Home class from ScopeType.CONVERSATION to any other scope type it works fine. I tried ScopeType.APPLICATION, ScopeType.EVENT, and ScopeType.SESSION and things reload properly. I've tried turning on TRACE level debug on the org.jboss.seam to see if I could see any other information and I don't see anything.


                  Here is my class that extends Home, I can't make it any simpler.


                  public class DummyHome extends Home<EntityManager, Dummy> {
                      private static final long serialVersionUID = -1L;
                  
                      @Override
                      protected String getPersistenceContextName() {
                          return "entityManager";
                      }
                  
                      private Dummy dummy = new Dummy();
                  
                      public Dummy getInstance() {
                          return dummy;
                      }
                  
                      @Override
                      protected String getEntityName() {
                          return "Dummy";
                      }
                  }



                  Here is the full stack trace of the Exception. Pete, Gavin (any ideas) Help please.


                  ERROR [ManagerBase] Exception loading sessions from persistent storage
                  java.lang.ClassNotFoundException: org.safmt.invmi.action.DummyHome
                       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                       at java.security.AccessController.doPrivileged(Native Method)
                       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
                       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
                       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                       at java.lang.Class.forName0(Native Method)
                       at java.lang.Class.forName(Class.java:247)
                       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:292)
                       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:1119)
                       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:798)
                       at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:441)
                       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                       at java.lang.Class.forName0(Native Method)
                       at java.lang.Class.forName(Class.java:247)
                       at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
                       at org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:78)
                       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
                       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
                       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
                       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                       at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
                       at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
                       at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
                       at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
                       at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1443)
                       at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:942)
                       at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394)
                       at org.apache.catalina.session.StandardManager.load(StandardManager.java:321)
                       at org.apache.catalina.session.StandardManager.start(StandardManager.java:637)
                       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4402)
                       at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
                       at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
                       at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
                       at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
                       at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
                       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                       at java.lang.reflect.Method.invoke(Method.java:597)
                       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
                       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
                       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
                       at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
                       at $Proxy38.start(Unknown Source)
                       at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
                       at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
                       at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
                       at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
                       at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                       at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
                       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                       at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
                       at org.jboss.system.ServiceController.start(ServiceController.java:460)
                       at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
                       at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
                       at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
                       at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
                       at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                       at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                       at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
                       at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
                       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
                       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                       at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                       at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
                       at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
                       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
                       at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
                       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
                       at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
                       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
                       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                       at java.lang.Thread.run(Thread.java:619)

                  • 6. Re: Session persistence across multiple deploys
                    asookazian

                    Most likely it's not designed to handle this situation.  File a JIRA.

                    • 7. Re: Session persistence across multiple deploys
                      dthompsn