1 Reply Latest reply on Jun 27, 2007 2:02 AM by Patrick Madden

    Bug? Seam-2.0-Beta - HttpSession Creation

    Patrick Madden Newbie

      Hi I've been using Seam 1.3.alpha for a while and I just upgraded to Seam 2.0 Beta from CVS on June 26th middle of the day. Just curious if there is a known problem with the following:

      In my web.xml I define some standard http session listeners as follows:

       <listener>
       <listener-class>com.clooster.web.context.SearchSessionListener</listener-class>
       </listener>
      


      The code for the listener is as follows:
      package com.clooster.web.context;
      
      import java.util.logging.Level;
      
      import javax.servlet.http.HttpSessionAttributeListener;
      import javax.servlet.http.HttpSessionBindingEvent;
      import javax.servlet.http.HttpSessionEvent;
      import javax.servlet.http.HttpSessionListener;
      
      import com.clooster.web.util.IdToSessionMap;
      import com.clooster.xjava.common.XSystem;
      
      /**
       *
       * @author PatrickMadden
       *
       */
      public class SearchSessionListener implements HttpSessionListener, HttpSessionAttributeListener
      {
       public SearchSessionListener()
       {
       super();
       XSystem.logInfo("Search Session Listener Allocation");
       }
      
       public void sessionCreated(HttpSessionEvent evt)
       {
       XSystem.logInfo("Session Created = " + evt.getSession().getId());
       IdToSessionMap.getInstance().addHttpSession(evt.getSession());
       SessionController.getInstance(evt.getSession().getId());
       }
      
       public void sessionDestroyed(HttpSessionEvent evt)
       {
       XSystem.logInfo("Session Destroyed = " + evt.getSession().getId());
       IdToSessionMap.getInstance().removeHttpSession(evt.getSession());
       SessionController.freeInstance(evt.getSession().getId());
       }
      
       public void attributeAdded(HttpSessionBindingEvent evt)
       {
       logSesionBindingEvent("Added Session attribute: {0} and value: {1}.", evt);
       }
      
       public void attributeRemoved(HttpSessionBindingEvent evt)
       {
       logSesionBindingEvent("Removed Session attribute: {0} and value: {1}.", evt);
       }
      
       public void attributeReplaced(HttpSessionBindingEvent evt)
       {
       logSesionBindingEvent("Replaced Session attribute: {0} and value: {1}", evt);
       }
      
       protected void logSesionBindingEvent(String msg,
       HttpSessionBindingEvent evt)
       {
       Object[] params = new Object[2];
       params[0] = evt.getName();
       params[1] = evt.getValue();
      
       if (XSystem.isLoggable(Level.FINE))
       XSystem.log(Level.FINE, msg, null, params);
       params = null;
       }
      }
      


      However when the above session created method is called I end up in an endless loop resulting in crap. Not sure if it is my problem but I created a new project using the new Seam Gen and grabbed my old code and put it in the new project.

      Here is the call stack once SessionCreated gets called:


      01:15:50,171 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:16:29,031 ERROR [STDERR] Jun 27, 2007 1:16:29 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = 712DBE64DDDD4035CA78D696353AC6C7
      01:16:57,968 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:16:58,000 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:17:00,062 ERROR [STDERR] Jun 27, 2007 1:17:00 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = 9BEFD3CEB5AA329B2B1C74F0718EF8AC
      01:17:01,031 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:17:01,046 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:17:01,765 ERROR [STDERR] Jun 27, 2007 1:17:01 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = 6CF43352A77FE107B9AC9E1D2B73FE13
      01:17:48,656 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:17:48,656 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:17:50,906 ERROR [STDERR] Jun 27, 2007 1:17:50 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = BFB33DC9C2BE5EA4EDDA3A5D4315D71C
      01:17:50,906 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:17:50,906 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:17:51,921 ERROR [STDERR] Jun 27, 2007 1:17:51 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = 17CE9ADF31DF5A8299E6A307BF4CC3B9
      01:17:51,921 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:17:51,921 INFO [Contexts] starting up: org.jboss.seam.web.session
      01:17:52,953 ERROR [STDERR] Jun 27, 2007 1:17:52 AM com.clooster.web.context.SearchSessionListener sessionCreated(SearchSessionListener.java:28)
      INFO: Session Created = 920F420E569E95A6E7D163A631B876F1
      01:17:52,953 INFO [Contexts] starting up: org.jboss.seam.security.identity
      01:17:52,968 INFO [Contexts] starting up: org.jboss.seam.web.session


      Any Help is Greatly Appreciated as I really need those session maps to deal with some Flex/Flash components that I'm using.

      BTW, using the new Red Hat Developer Studio stuff and the two way modification ability already saved me a lot of time with some stupid CSS stuff I was dealing with.

      Thanks again and looking forward to the final release of Seam/RichFaces!!!! You guys do great work.

      PVM

        • 1. Re: Bug? Seam-2.0-Beta - HttpSession Creation
          Patrick Madden Newbie

          Hi,

          I have a workaround for this but I can't imagine that its something you all will be happy with.

          For the sessionCreated and sessionDestroyed methods I simply put them in a runnable and called them later.

          It appears that as soon as I call HttpSessionEvent.getSession() is when the recursive loop occurrs.

          Anyway here is my workaround for now:

           public void sessionCreated(final HttpSessionEvent evt)
           {
           Runnable runner = new Runnable()
           {
           public void run()
           {
           XSystem.logInfo("Session Created = " + evt.getSession().getId());
           IdToSessionMap.getInstance().addHttpSession(evt.getSession());
           SessionController.getInstance(evt.getSession().getId());
           }
           };
          
           EventQueue.invokeLater(runner);
          
           }
          
           public void sessionDestroyed(final HttpSessionEvent evt)
           {
           Runnable runner = new Runnable()
           {
           public void run()
           {
           XSystem.logInfo("Session Destroyed = " + evt.getSession().getId());
           IdToSessionMap.getInstance().removeHttpSession(evt.getSession());
           SessionController.freeInstance(evt.getSession().getId());
           }
           };
          
           EventQueue.invokeLater(runner);
           }
          


          Looking forward to know whether or not I'm crazy :)

          Thanks,

          PVM