JSF does not populate @Named @RequestScoped bean with submitted input values

From your bean: import javax.faces.bean.RequestScoped; import javax.inject.Named; @Named(“loginRequest”) @RequestScoped public class LoginRequest { You’re mixing CDI and JSF annotations. You can and should not do that. Use the one or the other. I don’t know what’s the book is telling you, but most likely you have chosen the wrong autocomplete suggestion during the import of … Read more

NullPointerException while trying to access @Inject bean in constructor

You’re expecting that the injected dependency is available before the bean is constructed. You’re expecting that it works like this: RequestBean requestBean; requestBean.sessionBean = sessionBean; // Injection. requestBean = new RequestBean(); // Constructor invoked. This is however not true and technically impossible. The dependencies are injected after construction. RequestBean requestBean; requestBean = new RequestBean(); // … Read more

Where to use EJB 3.1 and CDI?

Yes, you can freely mix both CDI and EJB and achieve some great results. It sounds like you are using @WebService and @Schedule, which are good reasons for adding EJB to the mix. There’s a lot of confusion out there, so here is some general information on EJB and CDI as they relate to each … Read more

Changing faces-config.xml from 2.2 to 2.3 causes javax.el.PropertyNotFoundException: Target Unreachable, identifier ‘bean’ resolved to null

I would like to post a complete solution, what should be done in order to make JSF 2.3 libs work in JSF v2.3 mode. Code samples below are based on GlassFish 5.0 server environment. 1) Upgrade JSF libs to the version 2.3.3 at least (it fixes some bugs related to jsf 2.3 mode activation) 2) … Read more

CDI: beans.xml, where do I put you?

For EJB and JAR packaging you should place the beans.xml in src/main/resources/META-INF/. For WAR packaging you should place the beans.xml in src/main/webapp/WEB-INF/. Remember that only .java files should be put in the src/main/java and src/test/java directories. Resources like .xml files should be in src/main/resources.