title: Why is PostConstruct not called?
body: <p>I am working on a simple Java EE application.</p>
  
  <p>I have class like this:</p>
  
  <pre><code>import javax.annotation.PostConstruct;
  import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.Persistence;
  
  @Stateless
  public class BlogEntryDao {
  
      EntityManager em;
  
      @PostConstruct
      public void initialize(){
          EntityManagerFactory emf = Persistence.createEntityManagerFactory("Persistence");
          em = emf.createEntityManager();
      }
  
      public void addNewEntry(){
          Blogentry blogentry = new Blogentry();
  
          blogentry.setTitle("Test");
          blogentry.setContent("asdfasfas");
  
          em.persist(blogentry);
  
      }
  }
  </code></pre>
  
  <p>So my managed bean calls this method. Until here no problems. But since the initialize method is not called, I am getting an NPE in <strong>em.persist</strong>.</p>
  
  <p>Why is the initialize method not being called? I am running this on Glassfish server.</p>
  
  <p>Regards.</p>