2 Replies Latest reply on Jan 27, 2011 4:25 PM by nickarls

    @Named not working in JBoss 6

    aneaga

      The ear I deploy has the following structure

       

      EAR

             war

             lib\

                  jpa.jar

                  ejb.jar (references jpa.jar in MANIFEST)

       

       

      After LOTS of troubleshooting this is the topology that deploys fine and works fine in Glassfish. Only deploys fine in Jboss6M5 (same with today's noghtly Jboss build)

       

       

      Here's the bean I try to access in a JSF page:

       

      import javax.ejb.EJB;
      import javax.enterprise.context.RequestScoped;
      import javax.inject.Inject;
      import javax.inject.Named;
      import java.util.ArrayList;
      import java.util.List;

       

      @Named
      @RequestScoped
      public class BookController {

       

      .....

       

      Here's what I get:

       

      7:26:40,885 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] javax.el.PropertyNotFoundException: /listBooks.xhtml @49,57 action="#{bookController.doNew}": Target Unreachable, identifier 'bookController' resolved to null: javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /listBooks.xhtml @49,57 action="#{bookController.doNew}": Target Unreachable, identifier 'bookController' resolved to null

       

       

       

      I tried changing the @Named annotation to JSF's ManagedBean and then the error is that CDI cannot inject the beans BookController depends on.

       

      Please let me know what's wrong with this and why it works fine in latest Glassfish 3.

       

      Thanks.

        • 1. @Named not working in JBoss 6
          alex_vb

          I stumbled upon this page while researching a similar error (the JSF @ManagedBean annotation did work though). The fix to my problem was maddeningly easy: I had to add an (empty in this case) beans.xml to the WEB-INF folder. Only then does CDI kick in apparently.

           

          Hope it helps either you or the next stumbling guy!

          • 2. @Named not working in JBoss 6
            nickarls

            Yes, stick beans.xml in every META-INF and WEB-INF dir you can find ;-)