public WOActionResults performActionNamed(String name) {
// Generate responses for active sessions. If existingSession() returns null
// then there is no session ID (in a cookie or url) or the session has expired.
if (existingSession() == null) {
return null;
}
// The null pointer exception happens here because the code
// assumes that the session has some info (non-null) in it.
... code omitted here ...
}
So if the original session expired this method should be returning null. But it's not doing that. Instead, execution falls through and is getting to the code that assumes that the session is the original session and it tries to get some object that was stored in the session and then message that. But because a new session is created that object is null, and messaging it generates the null pointer exception.
Anyways, I can just add a null check but I'd like to understand why existingSession() is returning non-null which means there is an active (non-expired) session and yet when I call session() I get a different session object.
Or am I missunderstanding existingSession() here?
On Oct 28, 2008, at 8:43 PM, Chuck Hill wrote:
On Oct 28, 2008, at 5:37 PM, Ricardo J. Parada wrote:
I have a direct action that sometimes it gets a null pointer exception because some of the information previously stored in the session is no longer there and my code assumes it is there. Anyways, digging a little bit more I found out that the reason is doesn't find the information stored in the session is because the session() method is not returning the original session corresponding to the wosid in the URL. I made my direct action log the wosid from the URL and session().sessionID() and they are different:
wosid = iLdoMvh8zYtFsNsph9lltg
session().sessionID() = Hh5Qoar5sRzlXzwDnvBh0w
Anyways, does any body have any advise as to why this is happening? If the original session expired, would then session() return a new session?
Yes.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects