Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JBoss returns SessionFactoryImpl if we retrieve Persistence Unit though JNDI

Nitin Bhardwaj
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

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?

Best Regards,
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!