I'm trying to inject a DAO as a managed property.
public class UserInfoBean {
private User user;
@ManagedProperty("#{userDAO}")
private UserDAO dao;
public UserInfoBean() {
this.user = dao.getUserByEmail("[email protected]");
}
// Getters and setters.
}
The DAO object is injected after the bean is created, but it is null
in the constructor and therefore causing NullPointerException
. How can I initialize the managed bean using the injected managed property?