1 Reply Latest reply on Dec 14, 2005 6:01 PM by Anuj Shah

    StateLESS Session bean throws Could not passivate exception

    Anuj Shah Newbie

      Hi all,

      i am quite perplexed by this situation. My config is JBOSS 3.2.1 with Java and connecting to a postgres database. all my connections work just fine and our system is in good shape except one glitch.

      We are retrieving data from some external datasource. This process takes a good 20-30 minutes to come back. In all these activities we are using simple stateless session beans. one bean calls another and so on.

      Since it takes such a long time to come back, i believe JBOSS will obviously destroy some of the stateless session beans or ejbRemove them. So i have code to close the connection to a db in the remove method..

      however midway through those 20 minutes, i get a could not passivate exception. Here's the stack trace:

      javax.ejb.EJBException: Could not passivate; failed to save state; CausedByException is:
      org.jboss.resource.adapter.jdbc.WrappedConnection
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:378)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:85)
      at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractInstanceCache.java:156)
      at org.jboss.ejb.plugins.AbstractInstanceCache.release(AbstractInstanceCache.java:192)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.ageOut(LRUEnterpriseContextCachePolicy.java:274)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.kickOut(LRUEnterpriseContextCachePolicy.java:446)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.run(LRUEnterpriseContextCachePolicy.java:405)
      at java.util.TimerThread.mainLoop(Timer.java:432)
      at java.util.TimerThread.run(Timer.java:382)
      java.io.NotSerializableException: org.jboss.resource.adapter.jdbc.WrappedConnection
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:370)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:85)
      at org.jboss.ejb.plugins.AbstractInstanceCache.tryToPassivate(AbstractInstanceCache.java:156)
      at org.jboss.ejb.plugins.AbstractInstanceCache.release(AbstractInstanceCache.java:192)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.ageOut(LRUEnterpriseContextCachePolicy.java:274)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.kickOut(LRUEnterpriseContextCachePolicy.java:446)
      at org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy$OveragerTask.run(LRUEnterpriseContextCachePolicy.java:405)
      at java.util.TimerThread.mainLoop(Timer.java:432)
      at java.util.TimerThread.run(Timer.java:382)

      now here's a list of my questions, firstly I don't know which passivate method of which class does this call. I can put print statements and figure that out hopefully but that's a minor issue.

      here's the ejb methods of the class that contains the control when this exception is thrown...

      public void ejbCreate() throws CreateException {
      /** @todo Complete this method */
      Context ctx;
      try {
      ctx = new InitialContext();
      mCCEDataSource = (DataSource) ctx.lookup("java:/CCEDS");

      mNCBIProxy = new SeqHound(
      "C:\\jboss-3.2.1\\server\\default\\deploy\\.shoundremrc");
      mNCBIProxy.SHoundInit(true, "CCE");
      System.out.println("ejbCreate looked up CCEDS successfully");
      }
      catch (Exception e) {
      e.printStackTrace();
      throw new CreateException();
      }
      }


      public void ejbRemove() throws EJBException, RemoteException {

      try {
      if (mCCEDataSourceConnection != null) {
      mCCEDataSourceConnection.close();
      }
      mNCBIProxy.SHoundFini();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (SQLException e) {
      e.printStackTrace();
      }

      }

      Mind you this is a stateless session bean, (saw it in the ejb jar file). I don't know what else to post. I need some help debugging this and finding out what the exact problem is.

      Any pointers are appreciated.

      Thanks
      Anuj