title: JSF application scope instantiation and injection
body: <p>Probably my question is a trivial one, but I never used an application scope bean before. I need the application bean because I have to do time consuming transactions on the database.
  my search didn't satisfy my curiosity at all.
  I don't know why but I didn't manage to initialize the bean (it is null) or it the app crashed.
  So I have an application scope bean </p>
  
  <pre><code>@ManagedBean(eager=true)
  @ApplicationScoped
  public class ApplicationContainer {
  ...
  }
  </code></pre>
  
  <p>eager=true I read that tells JSF to initiate the bean every time when the application server (I use GlassFish) is started.</p>
  
  <p>I read in several places that I just have to put this annotation and the bean gets initialized.
  For me it doesn't...
  After I read that if I want to inject the application bean into another bean I have to use @PostConstuct annotation</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class TestsBean implements Serializable {
  
      private static final long serialVersionUID = 1L;
      @ManagedProperty(value = "#{container}")
      private ApplicationContainer container;
  
      @PostConstruct
      public void init() {
      container.contructContainer();
      }
  </code></pre>
  
  <p>this gives an error in other bean that I inject the TestsBean into...</p>
  
  <ul>
  <li>if the application bean gets initialized when the server starts what method does it call in the body of the application bean to do the actions that it requires? Or in the injected bean it's done in the post construct method?</li>
  </ul>
  
  <p>Please tell me the proper way to handle application beans. I an really confused...</p>
  
  <p>Thank you all for your time!</p>