2 Replies Latest reply on Oct 1, 2010 10:06 AM by Aldo Bonzi

    Injection NullPointerException

    omid pourhadi Apprentice

      Hi,
      I created an action seam component for registration and inject




      • EntityManager

      • FacesMessage



      and  everything goes fine until i created validator and inject it into Register component
      after that i wonder why everything i injected (enitityManager, facesmessage) turns to NULL ?


      RegisterValidator.java




      @Nmae("RegisterValidator")
      @AutoCreate
      public class RegisterValidator {
      
      @In Register Register;
      
      public boolean validate(String userName){
      if(!Register.isUserAvailable(userName))
      return true;
      }
      
      
      }
      



      Register.java




      @Name("Register")
      public class Register {
      
      @In EntityManager entityManager;
      
      @In RegisterValidator RegisterValidator;
      
      public void register(){
      if(RegisterValidator.validate)
      enitityManager.persist() // This is NULL
      }
      }