9 Replies Latest reply on May 24, 2005 8:59 AM by jonasl

    Could not passivate; failed to save state

    jonasl Newbie

      I get this error in my stateful session bean. Is there any ideas on how to solve this problem?


      15:02:24,781 WARN [AbstractInstanceCache] failed to passivate, id=e92p5p91-j
      javax.ejb.EJBException: Could not passivate; failed to save state; CausedByExcep
      tion is:
      org.jboss.mq.SpyQueueSender
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivate
      Session(StatefulSessionFilePersistenceManager.java:404)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(Stateful
      SessionInstanceCache.java:93)
      at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractIn
      stanceCache.java:180)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.ru
      n(LRUEnterpriseContextCachePolicy.java:419)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462)
      java.io.NotSerializableException: org.jboss.mq.SpyQueueSender
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)

      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
      :1369)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:13
      41)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.jav
      a:1284)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)

      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivate
      Session(StatefulSessionFilePersistenceManager.java:395)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(Stateful
      SessionInstanceCache.java:93)
      at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractIn
      stanceCache.java:180)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.ru
      n(LRUEnterpriseContextCachePolicy.java:419)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462)

        • 1. Re: Could not passivate; failed to save state
          Darran Lofthouse Master

          Your session bean contains a reference to something that can not be serialized by the container.

          java.io.NotSerializableException: org.jboss.mq.SpyQueueSender


          Within the ejbPassivate method you need to clear the references to anything that can not be serialized by the container.

          Have you got a QueueSender or something that you have not closed and set to null?

          If you have a look at the EJB 2.1 specification section 7.4.1 there is a list of what can be handled by the container.



          • 2. Re: Could not passivate; failed to save state
            jonasl Newbie

            Thank you for the reply.
            Yes I have a QueueSender initialized in ejbCreate.

            • 3. Re: Could not passivate; failed to save state
              jonasl Newbie

              I tried to set the QueueSender to null in ejbPassivate, and reactivate it in ejbActivate.

              It changes the error to:

              13:33:29,358 WARN [AbstractInstanceCache] failed to passivate, id=e941glx4-d
              javax.ejb.EJBException: Could not passivate; failed to save state; CausedByExcep
              tion is:
              org.jboss.resource.adapter.jdbc.WrappedConnection
              at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivate
              Session(StatefulSessionFilePersistenceManager.java:404)
              at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(Stateful
              SessionInstanceCache.java:93)
              at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractIn
              stanceCache.java:180)
              at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.ru
              n(LRUEnterpriseContextCachePolicy.java:419)
              at java.util.TimerThread.mainLoop(Timer.java:512)
              at java.util.TimerThread.run(Timer.java:462)
              java.io.NotSerializableException: org.jboss.resource.adapter.jdbc.WrappedConnect
              ion
              at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)

              at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
              :1369)
              at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:13
              41)
              at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.jav
              a:1284)
              at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)

              at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java
              :1369)
              at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:13
              41)
              at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.jav
              a:1284)
              at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)

              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
              at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivate
              Session(StatefulSessionFilePersistenceManager.java:395)
              at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(Stateful
              SessionInstanceCache.java:93)
              at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractIn
              stanceCache.java:180)
              at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.ru
              n(LRUEnterpriseContextCachePolicy.java:419)
              at java.util.TimerThread.mainLoop(Timer.java:512)
              at java.util.TimerThread.run(Timer.java:462)

              java.io.NotSerializableException: org.jboss.resource.adapter.jdbc.WrappedConnect
              ion


              Any hints on that one.

              • 4. Re: Could not passivate; failed to save state
                Ulf Schroeter Novice

                Think about it, as it is the same error as before !

                java.io.NotSerializableException: org.jboss.resource.adapter.jdbc.WrappedConnect
                ion
                



                This simply means, that you have an attribute of type org.jboss.resource.adapter.jdbc.WrappedConnect
                ion ( or mybe java.sql.Connection ) that is NOT serializable... like org.jboss.mq.SpyQueueSender

                Regards
                Ulf


                • 5. Re: Could not passivate; failed to save state
                  jonasl Newbie

                  Yes, but I dont know what that wrappecconnector is. I don´t have any sql code in my bean.

                  • 6. Re: Could not passivate; failed to save state
                    Ulf Schroeter Novice

                    Post your ejb class attribute section

                    • 7. Re: Could not passivate; failed to save state
                      jonasl Newbie

                      I had a logger class, that used a jdbc connection. Looks like it is working correct now - setting it to null in passivate etc.

                      At least no errors for 17 minutes now ;)

                      • 8. Re: Could not passivate; failed to save state
                        Darran Lofthouse Master

                        Don't forget to re-initialise the values in your ejbActivate method otherwise your next set of errors will be NullPointer exceptions when your code attempts to use the variables you have just set to null.

                        • 9. Re: Could not passivate; failed to save state
                          jonasl Newbie

                          Yes, I did do that.
                          Thanks alot for the help both of you.