Sulakshana Awsarikar wrote:
>
> I am starting another thread from my servlet and calling the
> HttpSession.getLastAccessedTime() in the run() of the thread.
> I am getting the following exception
>
What makes you think the session exists between
servlet calls? Maybe the session has been migrated
to another machine, maybe the session has been
saved to disk. Maybe the session is just gone because
the session has ended. Maybe the servlet container
has recycled parts of the session object (and will
recreate the session for you on the next request).
You're depending on behavior that's undefined in the
servlet spec, so you have to expect that things can
change. As you saw, upgrading versions of Tomcat
resulted in a change, as would using a different
servlet container.
As container implementors push the performance limits,
they will take advantage of more edge cases, and people
who depended on undefined behavior will start having
problems.
Starting threads in serlvets is (generally) a poor
idea. You have to be very, very careful to match
the lifecyle of the thread to the lifecycle of the
servlet/session/context. That's usally hard, and
sometimes impossible. Try:
http://www.distributopia.com/servlet_stuff/background_threads.txt
That's why J2EE prohibts EJB's from starting threads:
it's just a big fsck'ing mess. And if you think it's
hard to implement, just try explaining it to the
person who's trying to maintain the code across
container upgrades...
If you give some info about why you think you need
a thread, then maybe somebody here can suggest a
workaround.
--
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html