2 Replies Latest reply on Apr 23, 2010 4:05 AM by choicegh

    Application Scope Bean constructing twice

      Does anyone know why an ApplicationScope bean would be constructed twice?  I am finding this to be the case where the ApplicationScope bean resides in a JAR included on my projects classpath.


      Within my current project, the ApplicationScope beans are only constructed once as expected.


      I am using weld-se 1.0.1 in the junit testing environment.  I also see this behavior when deploying the application to Glassfish v3.


        • 1. Re: Application Scope Bean constructing twice
          swd847

          Are you sure it is the bean that is being constructed twice and not the bean and a proxy?


          to check stick something like this in the constructor:


          System.out.println("Constructing class: " + this.getClass().getName());
          
          

          • 2. Re: Application Scope Bean constructing twice

            I added the name of the class to the logging statement I already had in the constructor.  Indeed the first log was from a proxy.  The second from the class itself.


            In the constrictor I was reading a properties file in.  When I took that out ,thus making the constructor empty, only one logging statement occurred.


            I put the file load into an initial method annotated PostConstruct and I started getting the behavior I was expecting.