views:

304

answers:

2

In websphere (version 6 sp11) on request.getHeaderNames method call, i get this exception

java.lang.NullPointerException

            at com.ibm.ws.webcontainer.srt.SRTServletRequest.getHeaderNames(SRTServletRequest.java:345)

            at ....

I dont have source code for SRTServletRequest.

Has anybody faced this problem?

+1  A: 

One possible explanation for the NPE is given here.

I cannot be sure without looking at the WebSphere, but the diagnosis of the linked report an NPE in SRTServletRequest.getHeaderNames() says it can happen if you call the method on the request object has gone "out of scope". In other words, after the WebSphere container's lifecycle management has disposed of it. Now if this can happen when WebSphere is used with Spring, then it mostly likely can happen when WebSphere is used on its own.

If getHeaderNames() is called in doPost(), is it possible that your code has done something that causes WebSphere to think that the servlet has finished with the request object? It might be in the servlet or in something like a Filter that touched the request object earlier.

Stephen C
+1 Sounds like this is what's happening. The question is why...?
Matthew Murdoch
A: 

Finally, I have got the answer, thanks everyone for helping me out. the issue was: 1. a developer has saved a request in class field and 2. by the time class level request field is accessed, some other thread started and ended, hence destroy call and nullPointer.

zoli