10 Replies Latest reply on Nov 13, 2003 9:01 AM by thomas lehmann

    After 10-15 min of inactivity JBoss throws EJBException:coul

    stan2003 Newbie

      Hi !
      I have deployed simple entity bean and session bean with 2 methods, thats operate with entity. A simple client work with entity thru session bean. And all is good, but after 10-15 minutes of client inactivity, JBoss throws -->> EJBException: Could not passivate.
      Maybe I missed something in configurations ? (I'm novice in JBoss)

      My JBoss version 3.0.3, server - default. In config I changed only datasource (I use PostgreSQL).

      If have any idea's, please, tell me in this forum or via e-mail:
      ravik@pochta.ru
      P.S. Sorry me my bad english - I'm russian.
      Thanks to all !

        • 1. just one instance of a stateful session bean
          thomas lehmann Newbie

          Hello,

          I am trying to configure the container (Jboss 2.2.2) to instantiate no more than one instance of a stateful session bean. Unfortunately the container is creating more than one instance. Which I do not want, because the bean is meant to open a serial connection to a cellular phone.
          Any suggestions???

          Thanks,
          Ralph Hesse
          below is the jboss.xml configuration which I used!!!!!!!


          <?xml version="1.0" encoding="Cp1252"?>

          <enterprise-beans>
          <message-driven>
          <ejb-name>ListenerSMSBean</ejb-name>
          <configuration-name>Standard Message Driven Bean</configuration-name>
          <destination-jndi-name>queue/SMSQueue</destination-jndi-name>
          </message-driven>

          <ejb-name>SMSMessageBean</ejb-name>
          <configuration-name>SMSMessage Stateful SessionBean</configuration-name>

          false
          </enterprise-beans>
          <container-configurations>

          <container-configuration>
          <container-name>SMSMessage Stateful SessionBean</container-name>
          <call-logging>false</call-logging>
          <container-invoker>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker</container-invoker>
          <container-interceptors>
          org.jboss.ejb.plugins.LogInterceptor
          <!-- CMT
          -->
          org.jboss.ejb.plugins.TxInterceptorCMT
          org.jboss.ejb.plugins.MetricsInterceptor
          org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor
          <!-- BMT
          -->
          org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor
          org.jboss.ejb.plugins.TxInterceptorBMT
          org.jboss.ejb.plugins.MetricsInterceptor
          org.jboss.ejb.plugins.SecurityInterceptor
          </container-interceptors>
          <instance-cache>org.jboss.ejb.plugins.StatefulSessionInstanceCache</instance-cache>
          <persistence-manager>org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager</persistence-manager>
          <transaction-manager>org.jboss.tm.TxManager</transaction-manager>
          <container-invoker-conf>
          4444
          True
          </container-invoker-conf>
          <container-cache-conf>
          <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
          <cache-policy-conf>
          <min-capacity>1</min-capacity>
          <max-capacity>1</max-capacity>
          <overager-period>300</overager-period>
          <max-bean-age>600</max-bean-age>
          <resizer-period>400</resizer-period>
          <max-cache-miss-period>60</max-cache-miss-period>
          <min-cache-miss-period>1</min-cache-miss-period>
          <cache-load-factor>0.75</cache-load-factor>
          </cache-policy-conf>
          </container-cache-conf>
          <container-pool-conf>
          1
          </container-pool-conf>
          </container-configuration>
          </container-configurations>

          • 2. Re: After 10-15 min of inactivity JBoss throws EJBException:
            Raja Master

            You should be getting an exception stack trace along with this message. Are you sure your "db/sessions" directory under ur config is writeable? basically there is an IOException happening when the bean is written to disk .
            Can you post the stack trace? Check your server.log for a stacktrace
            -Raj

            • 3. Re: After 10-15 min of inactivity JBoss throws EJBException:
              L.G. Newbie

              Most likely you have some non-serializable object(s) in your beans.
              Use modifier transient for the object(s).

              • 4. Re: After 10-15 min of inactivity JBoss throws EJBException:
                stan2003 Newbie

                Here the stack trace:
                13:10:30,309 ERROR [Log4jService$ThrowableListenerLoggingAdapter] unhandled throwable
                javax.ejb.EJBException: Could not passivate; CausedByException is:
                javax.naming.InitialContext
                at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:293)
                at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:78)
                at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:615)
                at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:206)
                at java.lang.Thread.run(Thread.java:484)
                java.io.NotSerializableException: javax.naming.InitialContext
                at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
                at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1827)
                at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
                at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1214)
                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
                at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:287)
                at org.jboss.ejb.plugins.StatefulSessionInstanceCache.passivate(StatefulSessionInstanceCache.java:78)
                at org.jboss.ejb.plugins.AbstractInstanceCache$1.execute(AbstractInstanceCache.java:615)
                at org.jboss.util.WorkerQueue$QueueLoop.run(WorkerQueue.java:206)
                at java.lang.Thread.run(Thread.java:484)



                And I have permissions for writing to directory db/session

                • 5. Re: After 10-15 min of inactivity JBoss throws EJBException:
                  stan2003 Newbie

                  Already my session bean does not inplemented java.io.Serializable interface.
                  I re-write it. Now my session bean class implement Serializable interface, but problem still there. Stack trace is now available.

                  • 6. Re: After 10-15 min of inactivity JBoss throws EJBException:
                    Andreas Ecker Newbie

                    Seems like you hold the InitialContext for the lookups as global variable in your bean. Set it to null in the ejbPassivate() method and create a new instance in the ejbActivate() method.

                    Hope, that helps,

                    Andreas

                    • 7. Re: After 10-15 min of inactivity JBoss throws EJBException:
                      stan2003 Newbie

                      To Andreas:
                      Hi! Yes you write, I put set/unset code in ejbActivate/ejbPassivate
                      methods and it works !
                      Thanks, Andreas, and also thanks to raja05 and L.G.
                      I don't expect such quick answer's, it's a very good and helpfull forum.

                      Novikov Vitaliy.

                      • 8. Re: After 10-15 min of inactivity JBoss throws EJBException:
                        Lester LaForce Newbie

                        Will not coding set/unset functionality into a stateful sessions beans ejbActivate/ejbPassivate methods destroy its ?conversational? state?

                        I am a newbe, but I thought the purpose of persisting a stateful session bean was to maintain its conversational state (instance variables).

                        From O'Reilly Enterprise Java Beans (4th Edition) Page 325 (paragraph 5):

                        ?During the lifetime of a stateful session bean, there may be periods of inactivity when the bean instance is not servicing methods from the client. To conserve resources, the container can passivate the bean instance by preserving its conversation state and evicting the bean instance from memory. A bean?s conversation stat may consist of primitive values, object that are Serializable, and the following special types:

                        javax.ejb.SessionContext
                        javax.ejb EJBHome
                        javax.ejb EJNObject
                        javax.ejb Jta.UserTRansaction
                        javax.ejb Naming.Context(only when it references the JNDI ENC)
                        ??

                        My Jboss server (4.0) is throwing an exception because not all of the instance variables of the a session bean are primitives (or implement Serializable) -- when the container attempts to passivate the bean.

                        The problematic variable is an instance of javax.naming.Context. Of course, the JNDI context must be persisted between bean passivation and activation -- in order to preserve the conversational state So, once passivation of the fails, the server is locked -- the app must be un-deployed, then redeployed and the server ?bounced? (stopped and re-started) ? at the point, the bean has lost its former conversational state.

                        Page 325 (paragraph 5) of O?Rielly?s EJBs, states that the JNC may only be persisted when it references the JNDI ENC (Java Naming and Directory Interface Environment Naming Context ? the JNDI namespace).

                        What I understand is; the deployment descriptor provides a special set of tags for declaring remote EJB references in the JNDI ENC (page 315, O'Rielly?s EJB?s, paragraph 2). As, directed by the book, I have coded a set of < ejb-ref> tags for this bean in the ejb-jar.xml.

                        But I am still getting the same fatal behavior from the server.

                        • 9. Re: After 10-15 min of inactivity JBoss throws EJBException:
                          thomas lehmann Newbie

                          Hi all,

                          as far as I understand the O'Reilly book, lesterlaforce is completely rigth. In this book there is no example that sets the initialContext field to null in the ejbPassivate() method. Does anyone has a better solution?

                          Regards,
                          thomas

                          • 10. Re: After 10-15 min of inactivity JBoss throws EJBException:
                            Scott Stark Master

                            There is no conversational state in any jndi context so mark it as transient and restore it on activation.