title: Getting Entitymanager/EJB inside a @FacesConverter/Validator of a WAR-packaged app
body: <p>I have a JavaEE6-application running on Glassfish v3.0.1 with EJB 3.1 (app is packaged as WAR), and all my EJBs are @LocalBeans.
  Currently, i'm writing a FacesConverter for use in JSF2, in which i need the EntityManager to get an Entity back from an id. </p>
  
  <p>Now i wonder, which is the <em>best</em> and cleanest way to get the Entitymanager inside the FacesConverter, now that we are on JEE6? Or can i even access an EJB through the Expression Language? And Weld/CDI doesn't work inside a FacesConverter, or does it?</p>
  
  <pre><code>@FacesConverter(value="subscriptionListConverter")
  class SubscriptionListConverter extends Converter {
    public Object getAsObject(FacesContext ctx, UIComponent comp, String value) {
      var id:Long = Long.parseLong(value);
      // How to get the entitymanager?
      return em.find(User.getClass, id);
    }
  
    public String getAsString(ctx:FacesContext, comp:UIComponent, value:Object) {...}
  }
  </code></pre>
  
  <p>Sorry i hope this is no duplicate, but most cases i saw where slightly different and didn't help me much.</p>