@Named does not work JSF

Asked

Viewed 595 times

3

I am doing a project with jsf 2 and glassfish server when I put @Named in my bean the attributes get null only works with @Managedbean someone has already gone through this problem

2 answers

5

This happens because the annotation @Named is part of the package javax.inject, that can be consumed by JSF but is not part of the technology itself. Use a complete Java EE container such as Glassfish or Wildfly that already provide an implementation of the Dependency Injection for Java (JSR 330) and the CDI (JSR 346) for its application. In containers like Tomcat or Jetty you will need to provide and configure a CDI implementation (such as Weld), and, depending on the case, an implementation of Dependency Injection (as Google Guice) manually.

  • Thanks Anthony I am using glassfish, I found the problem was in my import had imported the javax.faces.bean library and the correct one was javax.enterprise.context thanks for the help

  • Opa, perfect, accept the reply of our colleague Alan then who was the one who described the problem.

4


Take a look at your import, you may be using some library erroneously or you are not importing something you need.
Put a snippet of your code so we can help more effectively.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.