@EJB
s are injected after bean's construction. It's for the EJB injection manager namely not possible to call a bean setter method before constructing it:
overzichtAlle.setEjbFacade(ejbFacade);
OverzichtAlle overzichtAlle = new OverzichtAlle();
Instead, the following is happening behind the scenes:
OverzichtAlle overzichtAlle = new OverzichtAlle();
overzichtAlle.setEjbFacade(ejbFacade);
So the ejbFacade
is not available inside bean's constructor. The normal approach is to use a @PostConstruct
method for this.
@PostConstruct
public void init() {
projE = ejbFacade.findAll();
omvormenProjectTypes();
}
A @PostConstruct
method is called directly after bean's construction and all managed property and dependency injections. You can do your EJB-dependent initializing job in there. The following will then happen behind the scenes:
OverzichtAlle overzichtAlle = new OverzichtAlle();
overzichtAlle.setEjbFacade(ejbFacade);
overzichtAlle.init();
Note that the method name doesn't matter. But init()
is pretty self-documenting.