我隐含地调用request.getAttribute(“atg.parent.session.id”)时会发生一些NPE。堆栈跟踪在下面(包含在跟踪日志之间)。
[2012/02/03 12:53:26:953 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getHeader this->com.ibm.ws.webcontainer.srt.SRTServletRequest@14f314f3: name --> SOAPAction header --> "http://acme.com/services/pick/SubmitOrder2"
[2012/02/03 12:53:26:953 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream fill fill
[2012/02/03 12:53:26:960 SAST] 00000162 channel 1 com.ibm.ws.webcontainer.channel.WCCByteBufferInputStream bufferIsGood buffer is good remaining --> 1635
[2012/02/03 12:53:26:960 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream read read length -->2048
[2012/02/03 12:53:26:960 SAST] 00000162 channel 1 com.ibm.ws.webcontainer.channel.WCCByteBufferInputStream bufferIsGood buffer is good remaining --> 1123
[2012/02/03 12:53:26:960 SAST] 00000162 channel 1 com.ibm.ws.webcontainer.channel.WCCByteBufferInputStream read Reset requested len --> 1574 to size remaining in current buffer --> 1123
[2012/02/03 12:53:26:960 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream read read returning -->1597, total=1635,limit=1635
[2012/02/03 12:53:26:961 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream read read length -->2048
[2012/02/03 12:53:26:962 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream read Over the limit: -1
[2012/02/03 12:53:26:962 SAST] 00000162 http > com.ibm.ws.webcontainer.srt.http.HttpInputStream close ENTRY total=1635,limit=1635
[2012/02/03 12:53:26:962 SAST] 00000162 http 1 com.ibm.ws.webcontainer.srt.http.HttpInputStream finish finish
[2012/02/03 12:53:26:962 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletResponse isSkipInputStreamRead skipInputStreamRead = false
[2012/02/03 12:53:26:962 SAST] 00000162 http < com.ibm.ws.webcontainer.srt.http.HttpInputStream close RETURN total=1635,limit=1635
[2012/02/03 12:53:26:964 SAST] 00000162 PickingManage I com.acme.services.pick.PickingManagementHttpBindingImpl submitOrder2 Method: submitOrder2
[2012/02/03 12:53:26:967 SAST] 00000162 webapp 1 com.ibm.ws.webcontainer.webapp.WebAppDispatcherContextImpl isSecurityEnabledForApplication serverSecurityEnabled
[2012/02/03 12:53:26:967 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getRemoteUser (security enabled)--> user XXXX
[2012/02/03 12:53:26:968 SAST] 00000162 PickingManage I com.acme.services.pick.PickingManagementHttpBindingImpl getUsername current user is: XXXX
[2012/02/03 12:53:26:971 SAST] 00000162 channel 1 com.ibm.ws.webcontainer.channel.WCCRequestImpl getHeader header --> Axis/1.4
[2012/02/03 12:53:26:971 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getHeader this->com.ibm.ws.webcontainer.srt.SRTServletRequest@14f314f3: name --> user-agent
[2012/02/03 12:53:27:564 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getAttribute this->com.ibm.ws.webcontainer.srt.SRTServletRequest@28e428e4: name --> atg.parent.session.id
[2012/02/03 12:53:27:565 SAST] 00000162 SystemOut O /com/acme/order/picking/PickingService An exception occurred: java.lang.NullPointerException java.lang.NullPointerException
at com.ibm.ws.webcontainer.srt.SRTServletRequest$SRTServletRequestHelper.access$200(SRTServletRequest.java:2629)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getAttribute(SRTServletRequest.java:276)
at atg.servlet.MutableHttpServletRequest.getAttribute(MutableHttpServletRequest.java:505)
at atg.servlet.MutableHttpServletRequest.getAttribute(MutableHttpServletRequest.java:470)
at atg.servlet.NameContextManager.getNameContextId(NameContextManager.java:320)
at atg.servlet.ServletUtil.getParentSessionId(ServletUtil.java:558)
at atg.commerce.messaging.CommerceMessageImpl.<init>(CommerceMessageImpl.java:230)
at com.acme.fulfillment.PickingMessage.<init>(PickingMessage.java:5)
at com.acme.order.picking.PickingService.submitOrder(PickingService.java:128)
at com.acme.services.pick.PickingManagementHttpBindingImpl.submitOrder2(PickingManagementHttpBindingImpl.java:177)
at com.acme.services.pick.PickingManagementHttpBindingSkeleton.submitOrder2(PickingManagementHttpBindingSkeleton.java:165)
at sun.reflect.GeneratedMethodAccessor1040.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:388)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:283)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
[2012/02/03 12:53:27:566 SAST] 00000162 SystemOut O
[2012/02/03 12:53:27:571 SAST] 00000162 PickingManage E com.acme.services.pick.PickingManagementHttpBindingImpl submitOrder2 An exception occurred: java.lang.NullPointerException
java.lang.NullPointerException
at com.ibm.ws.webcontainer.srt.SRTServletRequest$SRTServletRequestHelper.access$200(SRTServletRequest.java:2629)
at com.ibm.ws.webcontainer.srt.SRTServletRequest.getAttribute(SRTServletRequest.java:276)
at atg.servlet.MutableHttpServletRequest.getAttribute(MutableHttpServletRequest.java:505)
at atg.servlet.MutableHttpServletRequest.getAttribute(MutableHttpServletRequest.java:470)
at atg.servlet.NameContextManager.getNameContextId(NameContextManager.java:320)
at atg.servlet.ServletUtil.getParentSessionId(ServletUtil.java:558)
at atg.commerce.messaging.CommerceMessageImpl.<init>(CommerceMessageImpl.java:230)
at com.acme.fulfillment.PickingMessage.<init>(PickingMessage.java:5)
at com.acme.order.picking.PickingService.submitOrder(PickingService.java:128)
at com.acme.services.pick.PickingManagementHttpBindingImpl.submitOrder2(PickingManagementHttpBindingImpl.java:177)
at com.acme.services.pick.PickingManagementHttpBindingSkeleton.submitOrder2(PickingManagementHttpBindingSkeleton.java:165)
at sun.reflect.GeneratedMethodAccessor1040.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:388)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:283)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
[2012/02/03 12:53:27:586 SAST] 00000162 srt > com.ibm.ws.webcontainer.srt.SRTServletResponse setStatus ENTRY status --> 500 [com.ibm.ws.webcontainer.srt.SRTServletResponse@15651565]
[2012/02/03 12:53:27:586 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletResponse getRequest request=com.ibm.ws.webcontainer.srt.SRTServletRequest@14f314f3
[2012/02/03 12:53:27:587 SAST] 00000162 srt 1 com.ibm.ws.webcontainer.srt.SRTServletRequest getWebAppDispatcherContext
所以最初,线程很乐意使用请求 @ 14f314f3 。然后,由于一个未知的原因,它试图从一个不同的请求( @ 28e428e4 )中解除atg.parent.session.id,并在一切都出错后返回到原始请求( @ 14f314f3 )。
当发生此异常时,它将几乎总是重复,直到重新启动部署EAR的实例。似乎请求中有一些陈旧的数据,并且它以某种方式被保留,但我无法跟踪它。
PickingService组件的范围是“全局”,但它似乎是线程安全的。 CommerceMessageImpl的PickingMessage扩展重写了一个对请求没有影响的方法。
有没有办法让我弄清楚为什么/如何突然改变请求?所有实例和所有请求都不会始终如一地发生此问题。然而,它在我们的生产环境中造成了问题。任何帮助表示赞赏。