4 Replies Latest reply on Feb 8, 2010 7:37 AM by Arbi Sookazian

    Understanding qualifiers in the numberguess app

    Arbi Sookazian Master

      So out of curiosity (and to force myself to learn some stuff from the CDI spec an alternative way, by breaking the sample apps :), I did the following in the Generator class:


      /*@Produces @Random int next() { 
            return getRandom().nextInt(maxNumber); 
         }*/
         
         @Produces int next() { 
            return getRandom().nextInt(maxNumber); 
         }



      It seems to me that a qualifier is basically a way of achieving typesafe metadata for an object (rather than doing @Foo(value="bar").  But could someone plz explain how it works in this context and why I'm getting the below very long stack trace when I remove @Random?  The system is behaving as if it expects @Random to be there but it's not so it freaks out, naturally of course...


      So I get the following when I run the app:


      2010-02-06 17:26:51,162 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-127.0.0.1-8080-1) Error Rendering View[/home.xhtml]
      javax.el.ELException: /home.xhtml @14,119 rendered="#{game.number gt game.guess and game.guess ne 0}": Error reading 'number' on type org.jboss.weld.examples.numberguess.Game_$$_javassist_26
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:107)
           at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:416)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1604)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: org.jboss.weld.WeldException: WELD-000049 Unable to invoke method public void org.jboss.weld.examples.numberguess.Game.reset() on org.jboss.weld.examples.numberguess.Game@fbb1d8
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:537)
           at org.jboss.weld.bean.ManagedBean$1.postConstruct(ManagedBean.java:227)
           at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:148)
           at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:108)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:143)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:101)
           at org.jboss.weld.examples.numberguess.Game_$$_javassist_26.getNumber(Game_$$_javassist_26.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
           at org.apache.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:37)
           at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37)
           at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
           ... 37 more
      Caused by: java.lang.reflect.InvocationTargetException
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:235)
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:533)
           ... 56 more
      Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: class java.lang.Integer; binding types = [@Random]Unable to resolve any Managed Beans
           at org.jboss.weld.BeanManagerImpl.getBean(BeanManagerImpl.java:1074)
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:67)
           at org.jboss.weld.examples.numberguess.Game.reset(Game.java:90)
           ... 62 more
      2010-02-06 17:26:51,188 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/weld-numberguess].[Faces Servlet]] (http-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception
      javax.enterprise.inject.UnsatisfiedResolutionException: class java.lang.Integer; binding types = [@Random]Unable to resolve any Managed Beans
           at org.jboss.weld.BeanManagerImpl.getBean(BeanManagerImpl.java:1074)
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:67)
           at org.jboss.weld.examples.numberguess.Game.reset(Game.java:90)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:235)
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:533)
           at org.jboss.weld.bean.ManagedBean$1.postConstruct(ManagedBean.java:227)
           at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:148)
           at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:108)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:143)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:101)
           at org.jboss.weld.examples.numberguess.Game_$$_javassist_26.getNumber(Game_$$_javassist_26.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
           at org.apache.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:37)
           at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37)
           at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
           at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:416)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1604)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
      2010-02-06 17:26:59,535 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-127.0.0.1-8080-2) Error Rendering View[/home.xhtml]
      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.component.visit.VisitContextFactory
           at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)
           at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:306)
           at javax.faces.component.visit.VisitContext.createVisitContext(VisitContext.java:217)
           at javax.faces.component.visit.VisitContext.createVisitContext(VisitContext.java:234)
           at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:141)
           at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:126)
           at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:396)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
      2010-02-06 17:26:59,545 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/weld-numberguess].[Faces Servlet]] (http-127.0.0.1-8080-2) Servlet.service() for servlet Faces Servlet threw exception
      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.component.visit.VisitContextFactory
           at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)
           at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:306)
           at javax.faces.component.visit.VisitContext.createVisitContext(VisitContext.java:217)
           at javax.faces.component.visit.VisitContext.createVisitContext(VisitContext.java:234)
           at com.sun.faces.application.view.StateManagementStrategyImpl.saveView(StateManagementStrategyImpl.java:141)
           at com.sun.faces.application.StateManagerImpl.saveView(StateManagerImpl.java:126)
           at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:221)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:396)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
      2010-02-06 17:27:13,206 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http-127.0.0.1-8080-2) Error Rendering View[/home.xhtml]
      javax.el.ELException: /home.xhtml @14,119 rendered="#{game.number gt game.guess and game.guess ne 0}": Error reading 'number' on type org.jboss.weld.examples.numberguess.Game_$$_javassist_26
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:107)
           at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:416)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1604)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: org.jboss.weld.WeldException: WELD-000049 Unable to invoke method public void org.jboss.weld.examples.numberguess.Game.reset() on org.jboss.weld.examples.numberguess.Game@8eeaee
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:537)
           at org.jboss.weld.bean.ManagedBean$1.postConstruct(ManagedBean.java:227)
           at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:148)
           at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:108)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:143)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:101)
           at org.jboss.weld.examples.numberguess.Game_$$_javassist_26.getNumber(Game_$$_javassist_26.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
           at org.apache.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:37)
           at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37)
           at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
           ... 37 more
      Caused by: java.lang.reflect.InvocationTargetException
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:235)
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:533)
           ... 56 more
      Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: class java.lang.Integer; binding types = [@Random]Unable to resolve any Managed Beans
           at org.jboss.weld.BeanManagerImpl.getBean(BeanManagerImpl.java:1074)
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:67)
           at org.jboss.weld.examples.numberguess.Game.reset(Game.java:90)
           ... 62 more
      2010-02-06 17:27:13,236 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/weld-numberguess].[Faces Servlet]] (http-127.0.0.1-8080-2) Servlet.service() for servlet Faces Servlet threw exception
      javax.enterprise.inject.UnsatisfiedResolutionException: class java.lang.Integer; binding types = [@Random]Unable to resolve any Managed Beans
           at org.jboss.weld.BeanManagerImpl.getBean(BeanManagerImpl.java:1074)
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:67)
           at org.jboss.weld.examples.numberguess.Game.reset(Game.java:90)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:235)
           at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:533)
           at org.jboss.weld.bean.ManagedBean$1.postConstruct(ManagedBean.java:227)
           at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:148)
           at org.jboss.weld.context.AbstractMapContext.get(AbstractMapContext.java:108)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.getProxiedInstance(ClientProxyMethodHandler.java:143)
           at org.jboss.weld.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:101)
           at org.jboss.weld.examples.numberguess.Game_$$_javassist_26.getNumber(Game_$$_javassist_26.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
           at org.apache.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:37)
           at org.apache.el.parser.AstAnd.getValue(AstAnd.java:37)
           at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:71)
           at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
           at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
           at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:416)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1604)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
           at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)
           at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:68)
           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:183)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
           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.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:619)

        • 1. Re: Understanding qualifiers in the numberguess app
          Arbi Sookazian Master

          The beginning of the stack trace is misleading because I was able to step thru the reset() method below:


          @PostConstruct
             public void reset()
             {
                this.smallest = 0;
                this.guess = 0;
                this.remainingGuesses = 10;
                this.biggest = maxNumber;
                this.number = randomNumber.get();
             }

          • 2. Re: Understanding qualifiers in the numberguess app
            Nicklas Karlsson Master

            Because you do a @Inject @Random at some point but do no longer provide it anywhere. If it would be a direct injection instead of an Instance injection, it would have failed at deploy time.

            • 3. Re: Understanding qualifiers in the numberguess app
              Arbi Sookazian Master

              Ok, thx.  The following method is producing a @Random int :


              @Produces @Random int next() { 
                    return getRandom().nextInt(maxNumber); 
                 }



              which is expected to be available here:


              @Inject @Random Instance<Integer> randomNumber;

              • 4. Re: Understanding qualifiers in the numberguess app
                Arbi Sookazian Master

                Ok, to get some hands-on practice with the API and concepts, I wrote a Even interface:


                @Target( { TYPE, METHOD, PARAMETER, FIELD })
                @Retention(RUNTIME)
                @Documented
                @Qualifier
                public @interface Even
                {
                
                }



                and then did this in the Game class:


                @Inject @Random @Even Instance<Integer> randomNumber;



                which corresponds to this in the Generator class:


                @Produces @Even @Random int next() {
                        int randNum = getRandom().nextInt(maxNumber);
                        for (;;) {
                             if (randNum % 2 == 0) {
                                  System.out.println("randNum = "+randNum);
                                  return randNum;
                             }
                             else
                                  randNum = getRandom().nextInt(maxNumber);
                        }
                   }



                So I learned that CDI/Weld does not care about the order of the annotations (i.e. don't have to match at the injection and production points), that there is no JavaBeans-style requirement that the producer method must be a getter - in this case we see it's next(), and for both injections in the Game class it triggers the producer method invocations.


                Here: http://java.sun.com/javaee/6/docs/api/javax/inject/Inject.html
                it states that constructor, field, and method injection are all possible.


                How would I refactor the Game class to use method injection rather than field injection so that I can add debug brkpts and step into the methods?


                You can't add brkpts for field injection because there's no method there to add the brkpt (i.e. brkpts don't work on fields, only inside method bodies).


                I was thinking something like this:


                @Inject @MaxNumber
                   public int getMaxNumber(){
                        
                   }



                but I'm not sure what the method body should have (if anything at all and since it's not returning type void it must return an int).


                I also made the Game class ConversationScoped and a new conversation is being started when I open a new tab and navigate to http://localhost:8080/weld-numberguess/home.jsf.


                Is there any facility in Weld to see the list of LRC's like in the Seam debug page or this is going to be a PE in Seam3?