Replace
@FacesConverter(value = "categoryConverter")
by
@Named
and use
<h:inputSomething converter="#{categoryConverter}" />
or
<f:converter binding="#{categoryConverter}" />
instead of
<h:inputSomething converter="categoryConverter" />
or
<f:converter converterId="categoryConverter" />
By the way, similar problem exist for @EJB
inside a @FacesConverter
. It however offers a way to be grabbed by JNDI manually. See also Communication in JSF 2.0 – Getting an EJB in @FacesConverter and @FacesValidator. This way you can use a @FacesConverter(forClass=Category.class)
without manually defining it everytime. Unfortunately I can’t tell from top of head how to realize that for CDI beans.
Update: if you happen to use JSF utility library OmniFaces, since version 1.6 is adds transparent support for using @Inject
and @EJB
in a @FacesConverter
class without any additional configuration or annotations. See also the CDI @FacesConverter
showcase example.