我们在org.apache.catalina.connector.Request中的parseParemeters期间间歇性地执行NPE。在线用户越多,NPE发生的越多。在JBoss重启后,NPE会消失一段时间。在24小时内,我们会收到一到四百多名NPE。调用哪个服务并不重要。任何服务请求都可以在此NPE中结束。
java.lang.NullPointerException at org.apache.catalina.connector.Request.parseParameters(Request.java:2517) at org.apache.catalina.connector.Request.getParameterNames(Request.java:1102) at org.apache.catalina.connector.Request.getParameterMap(Request.java:1082) at org.apache.catalina.connector.RequestFacade.getParameterMap(RequestFacade.java:414) at javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:166) at org.jboss.seam.mock.MockExternalContext.getRequestParameterValuesMap(MockExternalContext.java:307) at org.jboss.seam.faces.Parameters.getRequestParameters(Parameters.java:61) at org.jboss.seam.Component.injectParameters(Component.java:1586) at org.jboss.seam.Component.inject(Component.java:1556) at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97) at org.jboss.seam.util.Work.workInTransaction(Work.java:61) at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at ExceptionInterceptor.aroundInvoke(ExceptionInterceptor.java:51) at sun.reflect.GeneratedMethodAccessor289.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:187) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:72) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) at TaskService_$$_javassist_seam_7.getNumberOfUpdatedTasks(TaskService_$$_javassist_seam_7.java) at sun.reflect.GeneratedMethodAccessor319.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.seam.remoting.gwt.GWTToSeamAdapter.callWebRemoteMethod(GWTToSeamAdapter.java:100) at org.jboss.seam.remoting.gwt.GWTService.RPC_invokeAndEncodeResponse(GWTService.java:550) at org.jboss.seam.remoting.gwt.GWTService.processCall(GWTService.java:206) at org.jboss.seam.remoting.gwt.GWTService$1.process(GWTService.java:120) at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53) at org.jboss.seam.remoting.gwt.GWTService.getResource(GWTService.java:105) at org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73) at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436) at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:384) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)
我们使用JBoss AS 5.1.0.GA,Seam 2.2.0.GA和GWT 2.0.3。 JBoss通过mod_jk接收来自Apache 2的请求。提供的行号(Request.java:2517)表示请求的方法为null,尽管firebug(client),Apache和mod_jk的日志显示该方法是POST。
目前,我们既不知道可能是NPE的根本原因,也不知道我们如何能够解决这个问题。我们猜测问题是否与此有关:
我们可以做些什么来找到这个问题的原因?有没有可能解决这个问题?
非常感谢任何帮助或建议。
谢谢!
-
我们很幸运,能够在NPE期间调试堆栈跟踪。我们发现MockExternalContext
中的请求对象并不总是与SeamResourceServlet
收到的请求对象匹配。有时,MockExternalContext
中的请求对象是新的,包含org.apache.coyote.Request
的全新实例,所有字段都设置为null
。如果可以处理请求,则SeamResourceServlet
收到的请求对象与MockExternalContext
中的请求对象相同。
任何Seam专家都可以帮助我们并告诉我们在上面的堆栈跟踪中何时何地创建MockExternalContext
使用的org.jboss.seam.faces.Parameters
? Seam在哪些情况下使用新的请求对象而不是MockExternalContext
提供的对象初始化SeamResourceServlet
?
我已在Seam forum中交叉发布此问题。
-
更新
与此同时,我们找到了NPE的原因:
由于我们在客户端使用GWT,所有客户端 - 服务器通信都是通过GWT-RPC异步完成的。很少,注销调用会导致另一个仍在处理的RPC。注销调用使会话无效,因此其他RPC无法正常完成,这导致ServletLifecycle.endRequest(request)期间出现异常;在ContextualHttpServletRequest中。此异常由Seam的ExceptionFilter处理。不幸的是,由于会话失效导致以下错误,ExceptionFilter也无法正常完成:
ERROR [Seam Resource Servlet].error: Servlet.service() for servlet Seam Resource Servlet threw exception java.lang.IllegalStateException: Cannot create a session after the response has been committed at org.apache.catalina.connector.Request.doGetSession(Request.java:2338) at org.apache.catalina.connector.Request.getSession(Request.java:2094) at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833) at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216) at org.jboss.seam.mock.MockExternalContext.getSessionMap(MockExternalContext.java:357) at org.jboss.seam.contexts.FacesLifecycle.beginExceptionRecovery(FacesLifecycle.java:86) at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:96) at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73) at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436) at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:384) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619)
在ExceptionFilter中创建的MockExternalContext,“以某种方式”保留在应用程序上下文中,并且“有时”用于处理请求。它甚至可以在我们的应用程序的重新部署中存活下来,因此我们必须重新启动JBoss才能摆脱NPE。
答案 0 :(得分:1)
非常感谢这篇文章。这个错误是我们几个星期的噩梦。我们的配置是:GWT 2.0.4,Seam 2.2.1 CR2,JBoss AS 5.1.0。我们在我们的应用程序中修补了注销机制,但它仍然返回(尽管很少)。现在看来,当事务在EJB层中持续太长时间时会发生这种情况。现在我们已经准备好摆脱Seam,它会导致比我们处理的问题更多的问题。
<强>更新强> 当“ServiceImpl”组件的范围从“SESSION”更改为默认值时,这个奇怪的bug完全消失了。还添加了注释@BypassInterceptors。同时我为我们的app准备了Seam-GWT桥的替代品。这是Guice + gwt-dispatch。非常快速可靠的解决方案。