1

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.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Bernhard
  • 2,023
  • 19
  • 21

1 Answers1

3

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 a.o. 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

See also:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
  • WOHOO: i just read http://showcase.omnifaces.org/cdi/FacesConverter and were suprised... thx - but how does the CDI-helper know about the session @BkkBean is using? i want to autocomplete jpa classes forth/back. – Bernhard Oct 12 '15 at 11:03