----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

   I have some problems with invalidating session under Jserv 1.0,
JServServletManger's household thread goes down and session don't get
invalidated. Apache error_log looks like this:

-------------8<-------------
java.lang.IllegalStateException: Session 3fd4f78081088156.101.940746432120
has been invalidated.
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Compiled Code)
        at java.lang.RuntimeException.<init>(RuntimeException.java:47)
        at
java.lang.IllegalStateException.<init>(IllegalStateException.java:45)
        at org.apache.jserv.JServSession.checkState(Compiled Code)
        at org.apache.jserv.JServSession.isNew(Compiled Code)
        at org.apache.jserv.JServServletManager.run(Compiled Code)
        at java.lang.Thread.run(Thread.java:485)
-------------8<-------------

   Because the checkState()-method called from JServSession.isNew()-method
throws IllegalStateException, shoudn't it be tried to catch in
JServServletManager.run()? Now it crashes the whole session management.

   Code from JServServletManager.run():

-------------8<-------------
            // walk through all sessions and invalidate old ones
            sesses = sessions.elements();
            sysMillis = System.currentTimeMillis();
            while(sesses.hasMoreElements()) {
                sess = (JServSession) sesses.nextElement();
                synchronized (sess) {
                    if ((sysMillis - sess.lastAccessTime > sessionTimeout)
||
                           ((sess.isNew()) &&
                           (sysMillis - sess.lastAccessTime >
newSessionTimeout))) {
                        try {
                            sess.invalidate();
                        }
                        catch (IllegalStateException ignored) {}
                    }
                }
            }
-------------8<-------------

   should be something like this:

-------------8<-------------
            // walk through all sessions and invalidate old ones
            sesses = sessions.elements();
            sysMillis = System.currentTimeMillis();
            while(sesses.hasMoreElements())

                sess = (JServSession) sesses.nextElement();
                synchronized (sess)

                  try

                    if ((sysMillis - sess.lastAccessTime > sessionTimeout)
||
                        ((sess.isNew()) &&
                         (sysMillis - sess.lastAccessTime >
newSessionTimeout)))

                      sess.invalidate();
                    }
                  } catch (IllegalStateException ignored) {}
                }
            }
-------------8<-------------

   I use JServ 1.0/Apache 1.3.9/Solaris

   By the way, should access to Enumeration sesses be synchronized?
Documentation on class Hashtable says "The Enumerations returned by
Hashtable's keys and values methods are not fail-fast"

        Tommi



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to