title: How to inject in @FacesValidator with @EJB, @PersistenceContext, @Inject, @Autowired
body: <p>How can I inject a dependency like <code>@EJB</code>, <code>@PersistenceContext</code>, <code>@Inject</code>, <code>@AutoWired</code>, etc in a <code>@FacesValidator</code>? In my specific case I need to inject a Spring managed bean via <code>@AutoWired</code>:</p>
  
  <pre><code>@FacesValidator("emailExistValidator")
  public class EmailExistValidator implements Validator {
  
      @Autowired
      private UserDao userDao;
  
      // ...
  }
  </code></pre>
  
  <p>However, it didn't get injected and it remains <code>null</code>, resulting in <code>java.lang.NullPointerException</code>.
  It seems that <code>@EJB</code>, <code>@PersistenceContext</code> and <code>@Inject</code> also doesn't work.</p>
  
  <p>How do I inject a service dependency in my validator so that I can access the DB?</p>