I have a problem with GlassFish 4.1.1 and Payara 4.1.153+.
The @Inject
points in the POJO converters no longer work. What did I miss? Has something changed in FacesConverter?
@FacesConverter("bkkConverter")
public class BkkConverter implements Converter,Serializable
{
@Inject
private BkkBean bkkBean;
...
bkkBean.fetchFromDatabase(...); <- NPE
The variable bkkBean
remains null
now. The Converter
itself works ( getAsObject
/ getAsString
), but no @Inject
?
It still works on GlassFish 4.1.
You were relying on an unspecified/undocumented feature. Mojarra 2.2 unintentionally supported @Inject
in @FacesConverter
, @FacesValidator
and @FacesComponent
before version 2.2.9 as consequence of a forgotten experiment/rollback. The support is expected to come in Mojarra 2.3 whereby an additional annotation attribute is required as in @FacesConverter(managed=true)
. See also ao issue 3552 .
In JSF 2.2 with CDI 1.1 your best bet is to manually grab the bean via CDI
utility class.
BkkBean bkkBean = CDI.current().select(BkkBean.class).get();
// ...
Alternatively, you can install OmniFaces in order to get transparent support for @Inject
(and @EJB
) in @FacesConverter
and @FacesValidator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.