4 Replies Latest reply on Oct 1, 2001 5:35 AM by Paul Austin

    jboss throw exception on passivate

    Verdi March Newbie

      I just create my stateful session bean. Every time
      I call .remove() from client (indicating I finish
      a "sessioon"), jboss print this kind of exception on
      console. Is my bean lack of something? Note that not
      all passivation would throw exception (I check this in
      server.log, some stateful bean passivate without
      exception):
      ================================================

      [Container factory] Scheduled passivation of bean SynchCatalog with id = 1001628096493
      [Bean Cache] Scheduling for passivation overaged bean SynchCatalog with id = 1001628096494 - Cache size = 12
      [Bean Cache] Aging out from cache bean SynchCatalogwith id = 1001628096494; cache size = 12
      [Container factory] Scheduled passivation of bean SynchCatalog with id = 1001628096494
      [Container factory] java.rmi.ServerException: Could not passivate; nested exception is:
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
      [Container factory] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:278)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:54)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:668)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:199)
      [Container factory] at java.lang.Thread.run(Thread.java:484)
      [Container factory] java.rmi.ServerException: Could not passivate; nested exception is:
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
      [Container factory] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:278)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:54)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:668)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:199)
      [Container factory] at java.lang.Thread.run(Thread.java:484)
      [Container factory] java.rmi.ServerException: Could not passivate; nested exception is:
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
      [Container factory] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:278)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:54)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:668)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:199)
      [Container factory] at java.lang.Thread.run(Thread.java:484)
      [Container factory] java.rmi.ServerException: Could not passivate; nested exception is:
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
      [Container factory] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:278)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:54)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:668)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:199)
      [Container factory] at java.lang.Thread.run(Thread.java:484)
      [Container factory] java.rmi.ServerException: Could not passivate; nested exception is:
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] java.io.NotSerializableException: org.opentools.minerva.jdbc.xa.wrapper.XAClientConnection
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
      [Container factory] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
      [Container factory] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
      [Container factory] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:278)
      [Container factory] at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:54)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:668)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:199)
      [Container factory] at java.lang.Thread.run(Thread.java:484)

      =======================

      And when I shut down JBOSs and look into server.log,
      there're additional exceptions like this:
      ======================
      [Container factory] java.lang.IllegalStateException: Attempt to put in the cache an object that is already there
      [Container factory] at org.jboss.util.LRUCachePolicy.insert(LRUCachePolicy.java:160)
      [Container factory] at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:678)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.flush(WorkerQueue.java:218)
      [Container factory] at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:194)
      [Container factory] at java.lang.Thread.run(Thread.java:484)

      ==========================


        • 1. Re: jboss throw exception on passivate
          Paul Austin Newbie

          Add the keyword transient infront of instance variables such as the database connection and see if that solves the problem

          • 2. Re: jboss throw exception on passivate
            Verdi March Newbie

            Actualy I expect client-class to use my bean in following steps:
            - open()
            - next()
            - close()

            So, I acquire connection in open(), and close that in
            close(), that's why I create an instance variable conn
            for conection. Meanwhile, in next(), I just traverse
            resultset (rs.next()). If I make conn transient, what
            about the resultset (also an instance variable), cause
            afaik, when resultset is avail. to gc if its statement
            or connection is closed/back to pool ?

            • 3. Re: jboss throw exception on passivate
              Verdi March Newbie

              Just check j2ee1.3 tutorial (from java.sun.com), I
              found my bean use similar flow with what BankBean.java
              use. It has a conn instance variable, do makeConnection()
              at ejbCreate(), and conn.close() at ejbRemove().

              Mine is similar too. In fact, my class has 3 primary
              instance variable: ResultSet rs, PreparedStatement
              stms, and Connection conn. I get connection in
              ejbCreate() and close it in ejbRemove(). In method open(),
              I get a prepare statemetn from conn, and execute a
              query ("hold" result with rs variable). In method next(),
              I just call rs.next() and do some other processing,
              until client call close() where I close both resultset
              rs and stmt.

              And the BankBean.java example don't use transient keyword
              for instance variable Connection either ?

              • 4. Re: jboss throw exception on passivate
                Paul Austin Newbie

                If you have to assume with Stateful session beans that your object may get passivated at some point, this would happen if the bean reached the age limit or the in memory cache was full. At this point the application server will call ejbPassivate on your bean and then try to serialize the bean to disk based storage.

                At this point any fields not marked as transient will be seriailized into the disk based file. If the object does not implement Serializable (as the java.sql stuff isn't) then you will get this exception. What you need to do in passivate is close all the result sets and connections and set any not serializable fields to null and store the current position in your result set.

                When the client invokes a method on the bean again it will load the state from the file and the call ejbActivate on your bean. In this method you would then reopen the database connection and execute a new query and then position the result set at the last row you processed.

                Paul