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