websphere 中 request.getHeaderNames 方法调用出现 nullpointerException
在 websphere(版本 6 sp11)中,在 request.getHeaderNames 方法调用上,我收到此异常,
java.lang.NullPointerException
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getHeaderNames(SRTServletRequest.java:345)
at ....
我没有 SRTServletRequest 的源代码。
有人遇到过这个问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
终于找到答案了,谢谢大家对我的帮助。
问题是:
1. 开发人员在类字段中保存了一个请求,并且
2. 当访问类级别请求字段时,其他一些线程启动并结束,因此销毁调用和 nullPointer。
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.
此处给出了 NPE 的一种可能解释。
如果不查看 WebSphere,我就无法确定,但是 SRTServletRequest.getHeaderNames() 中的链接报告的诊断表明,如果您在请求对象上调用该方法已“超出范围”,则可能会发生这种情况。 换句话说,在 WebSphere 容器的生命周期管理处理掉它之后。 现在,如果当 WebSphere 与 Spring 一起使用时会发生这种情况,那么当 WebSphere 单独使用时,它很可能会发生。
如果在 doPost() 中调用 getHeaderNames(),您的代码是否可能执行了某些操作,导致 WebSphere 认为 servlet 已完成请求对象的处理? 它可能位于 servlet 中,或者位于之前接触过请求对象的 Filter 之类的东西中。
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.