在org.apache.catalina.connector.Request中的parseParemeters期间,我们有Intertermittet NPE。在线用户越多,此NPE发生的次数就越多。重新启动JBoss之后,NPE会消失一段时间。在24小时内,我们会收到一到400多种NPE。调用哪个服务都没有关系。任何服务请求都可以在此NPE中结束。

java.lang.NullPointerException
        在org.apache.catalina.connector.Request.parseParameters(Request.java:2517)
        在org.apache.catalina.connector.Request.getParameterNames(Request.java:1102)
        在org.apache.catalina.connector.Request.getParameterMap(Request.java:1082)
        在org.apache.catalina.connector.RequestFacade.getParameterMap(RequestFacade.java:414)
        在javax.servlet.ServletRequestWrapper.getParameterMap(ServletRequestWrapper.java:166)
        在org.jboss.seam.mock.MockExternalContext.getRequestParameterValuesMap(MockExternalContext.java:307)
        在org.jboss.seam.faces.Parameters.getRequestParameters(Parameters.java:61)
        在org.jboss.seam.Component.injectParameters(Component.java:1586)
        在org.jboss.seam.Component.inject(Component.java:1556)
        在org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
        在org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        在org.jboss.seam.transaction.TransactionInterceptor $ 1.work(TransactionInterceptor.java:97)
        在org.jboss.seam.util.Work.workInTransaction(Work.java:61)
        在org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
        在org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        在org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
        在org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        在org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:163)
        在org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
        在ExceptionInterceptor.aroundInvoke(ExceptionInterceptor.java:51)
        在sun.reflect.GeneratedMethodAccessor289.invoke(未知来源)
        在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        在java.lang.reflect.Method.invoke(Method.java:597)
        在org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
        在org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:187)
        在org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:72)
        在org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
        在org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
        在org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
        在TaskService _ $$ _ javassist_seam_7.getNumberOfUpdatedTasks(TaskService _ $$ _ javassist_seam_7.java)
        在sun.reflect.GeneratedMethodAccessor319.invoke(未知来源)
        在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        在java.lang.reflect.Method.invoke(Method.java:597)
        在org.jboss.seam.remoting.gwt.GWTToSeamAdapter.callWebRemoteMethod(GWTToSeamAdapter.java:100)
        在org.jboss.seam.remoting.gwt.GWTService.RPC_invokeAndEncodeResponse(GWTService.java:550)
        在org.jboss.seam.remoting.gwt.GWTService.processCall(GW​​TService.java:206)
        在org.jboss.seam.remoting.gwt.GWTService $ 1.process(GWTService.java:120)
        在org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
        在org.jboss.seam.remoting.gwt.GWTService.getResource(GWTService.java:105)
        在org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)
        在javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:83)
        在org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:73)
        在org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
        在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        在org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        在org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
        在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
        在org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
        在org.jboss.web.tomcat.security.SecurityContext EstablishmentmentValve.process(SecurityContext EstablishmentmentValve.java:126)
        在org.jboss.web.tomcat.security.SecurityContext EstablishmentmentValve.invoke(SecurityContext EstablishmentmentValve.java:70)
        在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        在org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        在org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
        在org.apache.coyote.ajp.AjpProtocol $ AjpConnectionHandler.process(AjpProtocol.java:384)
        在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:447)
        在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(客户端),Apache和mod_jk的日志显示该方法为POST。

当前,我们既不知道NPE的根本原因,也不知道如何解决。我们正在推测问题是否与以下方面有关:


垃圾回收(JBoss从-Dsun.rmi.dgc.client.gcInterval = 3600000 -Dsun.rmi.dgc.server.gcInterval = 3600000开始)
在Tomcat中请求回收
Tomcat中的过滤器链回收
mod_jk平衡


我们该怎么做才能找到导致此问题的原因?这个问题有可能解决吗?

任何帮助或建议,我们将不胜感激。

谢谢!

-

我们很幸运,能够在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处理。不幸的是,由于无效的Session导致以下错误,ExceptionFilter也无法正常完成:

错误[Seam Resource Servlet] .error:Servlet的Servlet.service()Seam Resource Servlet抛出异常
java.lang.IllegalStateException:提交响应后无法创建会话
        在org.apache.catalina.connector.Request.doGetSession(Request.java:2338)
        在org.apache.catalina.connector.Request.getSession(Request.java:2094)
        在org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        在javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        在org.jboss.seam.mock.MockExternalContext.getSessionMap(MockExternalContext.java:357)
        在org.jboss.seam.contexts.FacesLifecycle.beginExceptionRecovery(FacesLifecycle.java:86)
        在org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:96)
        在org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:69)
        在org.jboss.seam.servlet.SeamFilter $ FilterChainImpl.doFilter(SeamFilter.java:73)
        在org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
        在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        在org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        在org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
        在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
        在org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
        在org.jboss.web.tomcat.security.SecurityContext EstablishmentmentValve.process(SecurityContext EstablishmentmentValve.java:126)
        在org.jboss.web.tomcat.security.SecurityContext EstablishmentmentValve.invoke(SecurityContext EstablishmentmentValve.java:70)
        在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        在org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        在org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
        在org.apache.coyote.ajp.AjpProtocol $ AjpConnectionHandler.process(AjpProtocol.java:384)
        在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:447)
        在java.lang.Thread.run(Thread.java:619)


在ExceptionFilter中创建的MockExternalContext“以某种方式”保留在应用程序上下文中,并且“有时”用于处理请求。它甚至可以在重新部署我们的应用程序后幸免于难,因此我们必须重新启动JBoss才能摆脱NPE。

最佳答案

非常感谢您提供这篇文章。这个错误是我们几个星期的噩梦。我们的配置是:GWT 2.0.4,Seam 2.2.1 CR2,JBoss AS 5.1.0。我们在应用程序中修补了注销机制,但它仍然返回(尽管很少)。现在看来,当事务在EJB层中持续太长时间时,就会发生这种情况。现在我们已经准备好摆脱Seam,它会导致更多问题,超出我们的处理能力。

更新:
当“ ServiceImpl”组件的作用域从“ SESSION”更改为默认值时,该奇怪的错误完全消失了。还添加了注释@BypassInterceptors。同时,我准备为我们的应用替换Seam-GWT桥。是Guice + gwt-dispatch。非常快速和可靠的解决方案。

关于tomcat - 在Tomcat请求中的parseParameters期间间歇地进行NPE,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3090283/

10-14 02:46