You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alistair Hopkins <al...@berthengron.co.uk> on 2000/08/15 18:36:33 UTC

Re: Retrieving Objects from the Session Results in a Null Pointer

I have a similar problem which I believe is related to automatic servlet 
reloading.

I stash a UsrDb object in the session at login, and use it for all sorts of 
things.

If I recompile any code (including non-servlet classes) then I get a 
java.lang.ClassCastException
caused by
                 UsrDb uCurrent = 
(UsrDb)request.getSession().getValue("UsrDb");

This is only a bit annoying as I restart the server and it's all fine.

Anybody else seen this?

At 09:18 AM 8/15/00 -0700, you wrote:
>I have this code:
>
><%
>theSession = request.getSession(false);
>
>shoppingCart cart = null;
>
>try {
>     cart = (shoppingCart)theSession.getValue("shoppingCart"); //This is
>causing a null pointer exception. Arghhhh...
>}
>catch (Exception e) {
>     e.printStackTrace();
>}
>%>
>
>that pulls an object out of the session...
>
>I can verify that the object is in the session. I can grab it from the page
>I inserted it from with this code:
>
>shoppingCart testCart = (shoppingCart)theSession.getValue("shoppingCart");
>
>I just can't get it from any other pages...
>
>Any ideas?
>
>
>Hunter Hillegas, MCP
>Web Engineer / System Administrator - Jacob Stern & Sons, Inc.
>hhillegas@jacobstern.com
>805-565-1411 PH * 805-565-8684 FAX