3 Replies Latest reply on Nov 9, 2012 8:04 AM by nimo22

    @ManagedBean(eager=true) with AS 7.1.1

    nimo22

      I have a application scoped bean with eager=true and expect that this bean loads during server start. But it does not!

       

       

      I am using common code

       

      {code}

      @Named

      @ManagedBean(eager=true)

      @ApplicationScoped

      public class MyEagerThing implements Serializable {

       

          private static final long serialVersionUID = -31177492927498099L;

       

          private static Logger log = Logger.getLogger(MyEagerThing.class);

       

          @Inject

          private Controller controller;

          @PostConstruct

          public void postConstruct() {

            log.infov("@PostConstruct: {0}", this.getClass().getSimpleName());

          }

      {code}

       

       

      Using Glassfish, "MyEagerThing" is loaded eagerly successfully.

      But with Jboss 7.1.1 FINAL, the eager does not work.

       

      Is this a bug?

        • 1. Re: @ManagedBean(eager=true) with AS 7.1.1
          nickarls

          Show your imports, which of the annotations are CDI and which JSF?

           

          The JSF @ManagedBean API says

           

          If the value of the eager() attribute is true, and the managed-bean-scope value is "application", the runtime must instantiate this class when the application starts.

           

          but then I think the @ApplicationScoped must be JSF and not CDI. @Named I guess is CDI but it shouldn't affect the issue.

           

          Message was edited by: Nicklas Karlsson

          • 2. Re: @ManagedBean(eager=true) with AS 7.1.1
            nimo22

            Okay I changed it to @Startup@Singleton and it works.

             

            However, I am wondering why it is not working with @ApplicationScoped.

            • 3. Re: @ManagedBean(eager=true) with AS 7.1.1
              nimo22

              Oh damned;) Yes you are right. I have had javax.enterprise.context.ApplicationScoped instead of the JSF-counterpart. I make a mistake with it again.

               

              Thank you!!