0 Replies Latest reply on Jun 8, 2011 4:33 AM by Assen Todorov

    Problem with @RequestParam

    Assen Todorov Newbie

      Hi,


      I have a problem to get a parameter from the GET-request.


      the entry point for my application is


      http://my.domain/?tid=101



      The parameter tid could be also send via POST-request to


      http://my.domain/



      I have also the following navigation rule


          <navigation-rule>
              <from-view-id>*</from-view-id>
      
              <navigation-case>
                  <if>#{not identity.loggedIn}</if>
                  <to-view-id>/login/login.xhtml</to-view-id>
                  <redirect/>
              </navigation-case>
      
          </navigation-rule>
      



      which redirects all the request to


      http://my.domain/?tid=101



      to the Login-page if the user is not already logged in.



      To pass the parameter tid from the entry-page to the application (for sake of simplicity I assume that it is send via GET) a wrote a custom servlet filter


      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
          {
              HttpServletRequest httpRequest = (HttpServletRequest)request;
              String tid = httpRequest.getParameter("tid ");
              if (tid != null)
              {
                  httpRequest.getSession().setAttribute("tid ", Long.parseLong(tid));
                 System.out.println("From filter : " + tid);
              }
              chain.doFilter(request, response);
          }



      In my AuthenticatorImpl I try to inject the GET-parameter like this :


         @Inject @RequestParam(value = "tid") @DefaultValue("123")
         private Instance<String> tid;
      



      After deploying my application i can see the output message from the servlet filter


      From filter : 101



      but if I try to login I get the following exception from WELD


      10:02:52,980 WARN  [org.jboss.seam.faces.environment.SeamApplicationWrapper] Cannot attempt extension on null
      10:02:52,980 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
      10:02:52,980 WARN  [org.jboss.seam.faces.environment.SeamApplicationWrapper] Cannot attempt extension on null
      10:02:53,027 ERROR [org.jboss.seam.security.IdentityImpl] Login failed: java.lang.RuntimeException: org.jboss.weld.exceptions.IllegalProductException: WELD-000052 Cannot return null from a non-dependent producer method:  [method] @Produces @Typed @RequestScoped protected org.jboss.seam.servlet.http.ImplicitHttpServletObjectsProducer.getHttpServletRequest()
           at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:329) [:3.0.0.Final]
           at org.jboss.seam.security.IdentityImpl.login(IdentityImpl.java:229) [:3.0.0.Final]
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_12]
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_12]
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_12]
           at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_12]
           at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.0.0.Final]
           at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.0.0.Final]
           at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
           at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
           at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
           at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
           at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) [:2.0.3-]
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) [:2.0.3-]
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) [:2.0.3-]
           at javax.faces.component.UICommand.broadcast(UICommand.java:311) [:2.0.3-]
           at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) [:2.0.3-]
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) [:2.0.3-]
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) [:2.0.3-]
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-]
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-]
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at my.application.beans.TenantFilter.doFilter(TenantFilter.java:42) [:]
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
           at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
           at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
           at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
           at java.lang.Thread.run(Thread.java:619) [:1.6.0_12]
      Caused by: org.jboss.weld.exceptions.IllegalProductException: WELD-000052 Cannot return null from a non-dependent producer method:  [method] @Produces @Typed @RequestScoped protected org.jboss.seam.servlet.http.ImplicitHttpServletObjectsProducer.getHttpServletRequest()
           at org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:256) [:6.0.0.Final]
           at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:362) [:6.0.0.Final]
           at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:121) [:6.0.0.Final]
           at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [:6.0.0.Final]
           at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) [:6.0.0.Final]
           at org.jboss.weld.proxies.org$jboss$weld$beanProducerMethod-org$jboss$seam$servlet$http$ImplicitHttpServletObjectsProducermethod_getHttpServletRequest()_$$_WeldClientProxy.getParameterMap(org$jboss$weld$beanProducerMethod-org$jboss$seam$servlet$http$ImplicitHttpServletObjectsProducermethod_getHttpServletRequest()_$$_WeldClientProxy.java)
           at org.jboss.seam.servlet.http.RequestParamProducer.isParameterInRequest(RequestParamProducer.java:91) [:3.0.0.Final]
           at org.jboss.seam.servlet.http.RequestParamProducer.getParameterValue(RequestParamProducer.java:87) [:3.0.0.Final]
           at org.jboss.seam.servlet.http.RequestParamProducer.getTypedParamValue(RequestParamProducer.java:62) [:3.0.0.Final]
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_12]
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_12]
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_12]
           at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_12]
           at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [:6.0.0.Final]
           at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [:6.0.0.Final]
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [:6.0.0.Final]
           at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [:6.0.0.Final]
           at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [:6.0.0.Final]
           at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [:6.0.0.Final]
           at org.jboss.seam.solder.bean.ImmutableNarrowingBean.create(ImmutableNarrowingBean.java:103) [:3.0.0.Final]
           at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:67) [:6.0.0.Final]
           at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:669) [:6.0.0.Final]
           at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:707) [:6.0.0.Final]
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:87) [:6.0.0.Final]
           at my.application.beans.authorization.AuthenticatorImpl.authenticate(AuthenticatorImpl.java:47) [:]
           at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:305) [:3.0.0.Final]
           ... 46 more
      



      What is wrong in my code?
      Any ideas are appreciated.