This week's book giveaway is in the Testing forum. We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line! See this thread for details.
JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI
posted 5 years ago
I deployed a persistence unit and the JBoss 6 server logs show that it has been successfully deployed and bound to JNDI with name: "persistence.unit:unitName=XCMS.war#XCMSPU". I've checked this also by visiting JMX-Console of JBoss viewing JNDI tree over there. I tried to lookup this persistence unit object through JNDI using the code:
The output returned is:
Nitin, The class of retrieved object is=org.hibernate.impl.SessionFactoryImpl
This could be because JBoss uses Hibernate as Persistence Provider (and I've also defined the same in persistence.xml). I was expecting this object to be of type javax.persistence.EntityManagerFactory.
Is there any way by which I can retrieve EntityManagerFactory using JNDI?
I know that by following code the container can inject the EntityManager:
However, I just want to get hold of EntityManagerFactory through JNDI. What should I do?