title: How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter?
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>@FacesConverter</code>? In my specific case I need to inject an EJB via <code>@EJB</code>:</p>
  
  <pre><code>@FacesConverter
  public class MyConverter implements Converter {
  
    @EJB
    protected MyService myService;    
  
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
      // myService.doSomething
    }
  
  }
  </code></pre>
  
  <p>However, it didn't get injected and it remains <code>null</code>, resulting in NPEs. It seems that <code>@PersistenceContext</code> and <code>@Inject</code> also doesn't work.</p>
  
  <p>How do I inject a service dependency in my converter so that I can access the DB?</p>