I have configured persistent unit ‘testDao’ in persistence.xml. And trying to create EntityManagerFactory and EntityManager using PersitentUnit and PersistentContext annotations as like this,
@PersistenceUnit(name = "testDao", unitName = "testDao")
private EntityManagerFactory emf = null;
@PersistenceContext(name = "testDao", unitName = "testDao")
protected EntityManager em;
But these two objects are not created. Am I doing anything wrong here. Please help me.
Hard to say for sure because there is not too much context, but most likely you are trying to use injection in class that is not container managed. Injection can be done only in container managed classes.
If that was the problem you are facing, you can find more details from this question: JBoss – User transaction not inited