@Named does not work JSF

Posted on

Question :

I’m doing a project with jsf 2 and glassfish server when I put @Named on my bean the attributes get null only works with @ManagedBean someone has already experienced this problem

    

Answer :

Take a look at your import, it may be that you are using a library incorrectly or you are not importing something that is needed.
Put a snippet of your code so we can help more effectively.

    

This happens because the @Named annotation is part of the javax.inject package, which 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 API ( JSR 330 ) and the CDI ( JSR 346 ) for your application. In containers such as Tomcat or Jetty you will need to make a CDI implementation available (such as Weld ). ), and, depending on the case, a Dependency Injection implementation (such as Google Guice ) manually.

    

Leave a Reply

Your email address will not be published. Required fields are marked *