WebSphere Application Server - Re: WAS6.1 - session.getAttribute( xxx) throwing a null pointer exception!

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > July 2007 > Re: WAS6.1 - session.getAttribute( xxx) throwing a null pointer exception!





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: WAS6.1 - session.getAttribute( xxx) throwing a null pointer exception!
Ken Hygh

2007-07-22, 7:18 pm

narasimha@vwebsol.com wrote:
> I am getting a Null Pointer Exception upon trying to access a session variable. Please note this issue is not the same as the session object being null or session variable being null. But here, trying to execute the line session.getAttribute itself thro

ws a null pointer with the below stack.
>
> =========================
> java.lang.NullPointerException
> at java.util.Hashtable.get(Hashtable.java:481)
> at com.ibm.ws.webcontainer.srt.SRTRequestContext.getSession(SRTRequestContext.java:76)
> at com.ibm.ws.webcontainer.srt.SRTServletRequest.getSession(SRTServletRequest.java:1239)
> at com.ibm.ws.webcontainer.srt.SRTServletRequest.getSession(SRTServletRequest.java:1226)
> at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:268)
> at com.ema.appfw.ui.web.AbstractMultiActionController. getUserSession(AbstractMultiActionContro
ller.java:37)
> ===========================
>
> The issue remains even if you request a new session (request.getSession(true)). Below is the Java code.
>
> if(request.getSession() != null) {
> if(request.getSession().getAttributeNames() != null && request.getSession().getAttributeNames().hasMoreElements())
> //get userSessionToken from Session
> userSession = (UserSession)request.getSession().getAttribute( AppConstants.USER_SESSION );
> }
>
> The issue occurs quite consistently on few requests after a little working with the application. In the sense, the user logs in, performs operation1, goes ahead to perform few other operations and then when he comes back to operation1 link, he gets the

above null pointer. It occurs with just single user session.
>
> Can anyone throw some light on the issue? Am I missing something in the application code or Websphere setting?
>
> Thanks in advance.
>
>
>


WAG 2: the variable 'request' is declared in object scope, and isn't
thread safe.
Ken
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com