2 Replies Latest reply on Mar 20, 2012 4:16 PM by Beat Fluri

    Incorrect request in MockExternalContext

    Beat Fluri Newbie

      We have troubles with incorrect HttpServletRequest objects in MockExternalContext: The request objects in MockExternalContext do not always match the request objects that the SeamResourceServlet receives. Sometimes the request object in MockExternalContext is a fresh instance of org.apache.coyote.Request with all fields set to null. That causes the following NullPointerException:


      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)



      If the request can be processed, the request objects received by SeamResourceServlet are identical to those in MockExternalContext.


      The NPE occurs randomly, i.e., it occurs between 0 and over a 100 times a day. The occurrence neither depends on the number of users online, on the request load, nor on the service method that is called. We use Seam 2.2.0.GA and GWT 2.0.3 with JBoss 5.1.0.GA. We have fixed GWTService to run with GWT 2.0.3 as suggested by JBSEAM-4506.


      Can any Seam expert please help us and tell when and where in the above stack trace the MockExternalContext that is used by org.jboss.seam.faces.Parameters is created? Under which circumstances does Seam initialize the MockExternalContext with a fresh request object rather than with the one provided by SeamResourceServlet?


      Thanks for your suggestions.