10 Replies Latest reply: May 24, 2012 1:51 PM by Scott Marlow RSS

    weld1.1.8 the @ PostConstruct in JBoss AS7.1.1.Final not execution

    振兴 周 Newbie

      In jboss as 7.1.1.final to perform weld1.1.8 the numberguess example, the openhome.xhml input box is unavailable, call the game when the rest () not implemented,then click the REST button the following error.

      Successful implementation of this example Glassfish3.1.2 within.

       

      The operating environment is as follows:

      win7 64bit

      eclipse EE 3.7.2 32bit

      jboss-as-7.1.1.Final

      weld-1.1.8.Final\examples\jsf\numberguess

       

      @Named

      @SessionScoped

      public class Game implements Serializable {

      .............

       

       

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

          public void validateNumberRange(FacesContext context, UIComponent toValidate, Object value) {
              if (remainingGuesses <= 0) {
                  FacesMessage message = new FacesMessage("No guesses left!");
                  context.addMessage(toValidate.getClientId(context), message);
                  ((UIInput) toValidate).setValid(false);
                  return;
              }
              int input = (Integer) value;

              if (input < smallest || input > biggest) {
                  ((UIInput) toValidate).setValid(false);

                  FacesMessage message = new FacesMessage("Invalid guess");
                  context.addMessage(toValidate.getClientId(context), message);
              }
          }

       

      .................

      }

      weld-jsf-numberguess

       

       

      http://localhost:8080/weld-jsf-numberguess/home.jsf

       

      <ui:composition template="/template.xhtml">

            <ui:define name="content">

               <h1>Guess a number...</h1>

               <h:form id="numberGuess">

                  <div style="color: red">

                     <h:messages id="messages" globalOnly="false"/>

                     <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess and game.guess ne 0}"/>

                     <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess and game.guess ne 0}"/>

                  </div>

         

                  <div>

                     I'm thinking of a number between <span id="numberGuess:smallest">#{game.smallest}</span> and <span id="numberGuess:biggest">#{game.biggest}</span>. You have #{game.remainingGuesses} guesses remaining.

                  </div>

            

                  <div>

                     Your guess:

                     <h:inputText id="inputGuess" value="#{game.guess}"

                        required="true" size="3" disabled="#{game.number eq game.guess}" validator="#{game.validateNumberRange}"/>

                     <h:commandButton id="guessButton" value="Guess" action="#{game.check}" disabled="#{game.number eq game.guess}"/>

                  </div>

                  <div>

                     <h:commandButton id="restartButton" value="Reset" action="#{game.reset}" immediate="true"/>

                  </div>

               </h:form>

            </ui:define>

         </ui:composition>

       

      type Exception report

      message

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      javax.servlet.ServletException: javax.el.PropertyNotFoundException: /home.xhtml @29,107 action="#{game.reset}": Target Unreachable, identifier 'game' resolved to null  javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)  org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)  

       

      root cause

      javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /home.xhtml @29,107 action="#{game.reset}": Target Unreachable, identifier 'game' resolved to null  javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95)  com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)  javax.faces.component.UICommand.broadcast(UICommand.java:315)  javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)  javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:935)  com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)  com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)  com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)  javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)  org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)  

       

      root cause