5 Replies Latest reply on Oct 24, 2002 5:24 AM by jules

    Stateful Session Bean within Servlet Problem

    tbrunia

      I am running JBoss 3.0.3 on Linux Redhat 7.1. I have written a servlet that uses a Stateful Session bean. My servlet init() code looks like this:

      public void init(ServletConfig config) throws ServletException {
      super.init(config);
      try {
      ServletContext context = getServletContext();

      DocumentAgentHome documentAgentHome =
      (DocumentAgentHome) getHome("java:comp/env/ejb/DocumentAgentHome", DocumentAgentHome.class);
      DocumentAgent documentAgent = documentAgentHome.create();
      context.setAttribute("documentAgent", documentAgent);

      CategoryAgentHome categoryAgentHome =
      (CategoryAgentHome) getHome("java:comp/env/ejb/CategoryAgentHome", CategoryAgentHome.class);
      CategoryAgent categoryAgent = categoryAgentHome.create();
      context.setAttribute("categoryAgent", categoryAgent);

      } catch (NamingException e) {
      throw new ServletException("Naming Exception:\n"+e.getMessage());
      } catch (RemoteException e) {
      throw new ServletException("Remote Exception:\n"+e.getMessage());
      } catch (CreateException e) {
      throw new ServletException("Create Exception:\n"+e.getMessage());
      }
      }

      The servlets destroy() method looks like this:



      /** Destroys the servlet.
      */
      public void destroy() {
      try {
      getServletContext().removeAttribute("documentAgent");
      getServletContext().removeAttribute("categoryAgent");

      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      The application works fine for about an hour. After about an hour I start receiving the following error in my server log.

      2002-10-16 16:01:19,936 WARN [org.jboss.jbossweb] WARNING: Exception for /inertia_repository/listByCategory.jsp: java.rmi.NoSuchObjectException: Could not activate; CausedByException is:
      /usr/jboss/jboss-3.0.3/server/default/db/sessions/CategoryAgentHome/1034735598095.ser (No such file or directory)

      Any help would be greatly appreciated.

        • 1. Re: Stateful Session Bean within Servlet Problem
          joelvogt

          stateful session beans will timout after a set time, causing the error you see. You can either edit standardjboss.xml, the stateful session bean section (increase timeouts), or maybe better (?) copy paste config to your jboss.xml and then edit so you can make changes for this app only

          • 2. Re: Stateful Session Bean within Servlet Problem

            Could your SSB have a one hour time out set ?

            Jules

            • 3. Re: Stateful Session Bean within Servlet Problem
              tbrunia

              Thank you very much for your responses. I am looking over my standardjboss.xml file. Here's what I have within the Standard Stateful SessionBean "container-configuration".

              <container-cache-conf>
              <cache-policy>org.jboss.ejb.plugins.LRUStatefulContextCachePolicy</cache-policy>
              <cache-policy-conf>
              <min-capacity>50</min-capacity>
              <max-capacity>1000000</max-capacity>
              <remover-period>1800</remover-period>
              <max-bean-life>1800</max-bean-life>
              <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>

              Shouldn't I expect my stateful session beans to be passivated after 600 sec (10 min) of inactivity? If this is true, wouldn't I expect to see a ***.ser file appear in the $JBOSS_HOME/server/default/db/sessions/[SessionBeanName]/ directory? This isn't happening.

              I've seen some other topic postings related to Stateful Sessions beans not being passivated.

              Could this be a JBoss bug?

              I have been able to repeat this problem with JBoss/Tomcat and on a Windows machine.

              • 4. Re: Stateful Session Bean within Servlet Problem
                tbrunia

                I tried deploying to the EJB 2.0 standard with no improvement.

                I am really stumped and frustrated with this one. Why is JBoss trying to activate Session beans that have not been passivated? It would appear this is the case.

                Is anyone else experiencing this problem?

                Regards,
                Todd Brunia

                • 5. Re: Stateful Session Bean within Servlet Problem

                  you are probably in the wrong forum to get a decent answer to this - this is probably not specifically a web problem

                  Jules