4 Replies Latest reply on Jun 12, 2009 2:08 PM by Arvinder Singh

    Faces Event > EJBTransactionRolledbackException > @In attribute requires non-null value

    Arvinder Singh Novice

      Hi


      I am following the examples from seam in action (www.manning.com/dallen) and am using an ear deployment instead of war.
      What I have here is a simple registration example, that used faces events to validate a field when an event is raised, like tab over the field.


      In summary, the main difference is that I am deploying this in an ear and I am not sure why this error is occuring - I have
      looked in the formums and tried adding this to the action, but nothing has worked:



      @In(create = true,required=true)
          protected PasswordBean passwordBean = new PasswordBean();



      RegisterBean





      @Stateless
      @Name("register")
      public class RegisterBean implements Register {
          @Logger
          private Log log;
      
          @In
          StatusMessages statusMessages;
      
          @In
          private Member newMember;
      
          @PersistenceContext
          private EntityManager entityManager;
      
          @In
          protected MemberValidator memberValidator;
      
          @In
          protected PasswordManager passwordManager;
      
          @In(create = true,required=true)
          protected PasswordBean passwordBean = new PasswordBean();
      
          @In
          private FacesMessages facesMessages;
      
          public String register() {
              ...
              return "success";
          }
      
          public boolean isUsernameAvailable(String username) {
              log.info("Checking if username is available " + username);
              return entityManager.createQuery(
                      "select m from Member m where m.username = :username")
                      .setParameter("username", username)
                      .getResultList().size() == 0;
          }
      
          public boolean isEmailRegistered(String email) {
              return entityManager.createQuery(
                      "select m from Member m where m.email = :email")
                      .setParameter("email", email)
                      .getResultList().size() > 0;
          }
      
          public void verifyUsernameAvailable(ValueChangeEvent e) {
              String username = (String) e.getNewValue();
              if (!isUsernameAvailable(username)) {
                  facesMessages.addToControl(e.getComponent().getId(),
                          "Sorry, username already taken");
              }
          }
      
          public void checkEmailRegistered(ValueChangeEvent e) {
              String email = (String) e.getNewValue();
              if (isEmailRegistered(email)) {
                  facesMessages.addToControl(e.getComponent().getId(),
                          "Sorry, email address is already registered");
              }
          }
      
      }
      







      Error



      08:40:07,016 ERROR [STDERR] 12-Jun-2009 08:40:07 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
      INFO: Added Library from: jar:file:/C:/projects/jboss-4.2.3.GA/server/default/deploy/example.ear/example.war/WEB-INF/li
      b/richfaces-ui.jar!/META-INF/richfaces.taglib.xml
      08:40:18,813 ERROR [AjaxViewRoot] Error processing faces event for the component registerActionForm:usernameField:username
      javax.faces.event.AbortProcessingException: /register.xhtml @28,65 valueChangeListener="#{register.verifyUsernameAvailable}":
      javax.ejb.EJBTransactionRolledbackException: @In attribute requires non-null value: register.passwordBean
              at javax.faces.event.MethodExpressionValueChangeListener.processValueChange





      Auth Package


      package-info.java




      @Namespace(value = "http://example.org/components/auth", prefix = "org.example.auth")
      @AutoCreate
      package com.example.app.ex.auth;
      import org.jboss.seam.annotations.AutoCreate;
      import org.jboss.seam.annotations.Namespace;






      PasswordBean



      @BypassInterceptors
      public class PasswordBean {
              private String password;
              private String confirm;
      
              public String getPassword() {
                      return password;
              }
              public void setPassword(String password) {
                      this.password = password;
              }
      
              public String getConfirm() {
                      return confirm;
              }
              public void setConfirm(String confirm) {
                      this.confirm = confirm;
              }
      
              public boolean verify() {
                      return confirm != null && confirm.equals(password);
              }
      }





      components.xml




      <import>org.example.auth</import>
       <auth:password-bean name="passwordBean" scope="event"/>