The Java EE bean annotations such as @PostConstruct
only apply to container-managed beans. If you are simply calling new BlogEntryDao
yourself, the container isn’t going to intercept the creation and call the @PostConstruct
method.
(Furthermore, you’d be better off using @PersistenceContext
or @PersistenceUnit
instead of manually fetching the EntityManagerFactory
in your initialize()
method, and you should be creating an EntityManager
for each call to addNewEntry()
, since they’re short-lived. Making these changes would eliminate the need for initialize()
at all.)