| Paul Ilechko 2007-07-21, 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?
>
WAG - you're going from a protected to an unprotected page, and no
longer have access to a secure session.
|