tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Objects lost in session
Date Tue, 30 Sep 2003 19:37:16 GMT

Howdy,
Strange indeed.  When things like this happen and you can't reproduce
them reliably, I tend to think of two always-present possible evils:

1. Thread safety: what happens if you make all the relevant methods
synchronized?  Shouldn't make much of a difference here since a request
is being served by one thread, but still worth trying.

2. GC?  If your system is really stressed when these errors happened,
this is worth investigating.  Perhaps the collector is collection your
session prematurely.  Again, theoretically unlikely if not impossible,
but those are the types of things that tend to happen under high stress.

You can use a load-testing tool (e.g. JMeter) to simulate high load on
your dev server, or alternatively to just run multiple concurrent tests
in order to look for thread-safety-related bugs.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Tim Odowd [mailto:todowd@PeopleAdmin.com]
>Sent: Tuesday, September 30, 2003 2:12 PM
>To: 'tomcat-user@jakarta.apache.org'
>Subject: Objects lost in session
>
>Sorry for the long email.
>
>I am using Tomcat 4.124 for my servlet engine and IIS for my web
server.
>
>I am monitoring exceptions that occur in my system and this one has me
>confused.  The exception is:
>java.lang.NullPointerException
>	at ParentClass.getQualificationMessage(ParentClass.java:483)
>	at ChildClass.finishDocumentUpload(ChildClass.java:135)
>	at ...
>
>The parent class method is failing when it tries to call a method on
the
>Position object that it retrieved from the session.
>It looks like the Position object is null in the session:
>
>    protected static final String getQualificationMessage(
>            HttpServletRequest request){
>        HttpSession session = request.getSession();
>        int employerId =
((Integer)session.getAttribute(RC.EMPLOYER_ID))
>        		.intValue();
>(483)        int positionId
>                =
>((Position)session.getAttribute(RC.POSITION)).getPositionId();
>		...
>
>What I can't explain is that the ChildClass method that has called the
>above
>method was able to retrieve the position object from the session and
call a
>method on it.  That makes me believe that the position object existed
in
>the
>session at that time:
>
>
>I have a Position object stored as a session attribute with the
attribure
>name RC.POSITION.
>
>    protected static final String finishDocumentUpload(
>            HttpServletRequest request, EmployerConfiguration ec){
>        HttpSession session =request.getSession();
>        Position position =
(Position)session.getAttribute(RC.POSITION);
>        if (position.attachDocumentsOnly()){
>        	return 	forwardToOriginalPage(request, ec);
>        } else {
>135	   	return getQualificationMessage(request);
>		}
>    }
>
>
>I cannot reproduce this error (which is making me crazy), but I see
similar
>things happening every once in a while in my exception log.
>
>Any ideas?
>
>Thanks for your help,
>-tim



This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


Mime
View raw message