Accessing injected dependency in managed bean constructor causes NullPointerException
Injection can only take place after construction simply because before construction there’s no eligible injection target. Imagine the following fictive example: UserInfoBean userInfoBean; UserDao userDao = new UserDao(); userInfoBean.setDao(userDao); // Injection takes place. userInfoBean = new UserInfoBean(); // Constructor invoked. This is technically simply not possible. In reality the following is what is happening: UserInfoBean … Read more