07-23-07 12:18 AM
narasimha@vwebsol.com wrote:
> I am getting a Null Pointer Exception upon trying to access a session variable. Pl
ease note this issue is not the same as the session object being null or session var
iable being null. But here, trying to execute the line session.getAttribute itself t
hro
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(SRTRequestCon
text.java:76)
> at com.ibm.ws.webcontainer.srt.SRTServletRequest.getSession(SRTServletReq
uest.java:1239)
> at com.ibm.ws.webcontainer.srt.SRTServletRequest.getSession(SRTServletReq
uest.java:1226)
> at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletReq
uestWrapper.java:268)
> at com.ema.appfw.ui.web.AbstractMultiActionController.getUserSession(Abst
ractMultiActionController.java:37)
> ===========================
>
> The issue remains even if you request a new session (request.getSession(tr
ue)). 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().getAttribu
te( AppConstants.USER_SESSION );
> }
>
> The issue occurs quite consistently on few requests after a little working with th
e application. In the sense, the user logs in, performs operation1, goes ahead to pe
rform few other operations and then when he comes back to operation1 link, he gets t
he
above null pointer. It occurs with just single user session.
>
> Can anyone throw some light on the issue? Am I missing something in the ap
plication code or Websphere setting?
>
> Thanks in advance.
>
>
>
WAG 2: the variable 'request' is declared in object scope, and isn't
thread safe.
Ken
[ Post a follow-up to this message ]
|