Hibernate: No Persistance Provider

While working through a code sample in Java Persistence with Hibernate, I ran into a problem where Hibernate was reporting No Persistence Provider. Solved the problem, and it wasn’t moving the persistence.xml file as you’d normally find on the web as the solution.

I’ve been spending a lot of time with Hibernate, an ORM persistence manager.

After ripping Pro Hibernate 3 a new one with a scathing review, I finally have concluded that the best book on Hibernate is Java Persistence with Hibernate, which is revised edition of Hibernate In Action, though you’ll still need to reference the ERRATA for Java Persistence with Hibernate on occasion.

In the middle of page 76 it was time to go build my sample application, and all I got was a strange message that said: javax.persistence.PersistenceException: No Persistence provider for EntityManager named helloworld


Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named helloworld
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)

Most of the discussions on the Web lead to the conclusion that the file persistence.xml is missing, or if it isn’t, it hasn’t been placed in the META-INF directory. In my case it was present, it was in the right place, and it was correct. What gives? Seems other people were having this problem as well.

The Solution
Thanks to a szermierz‘s entry on the introductory page An Introduction to Java Persistence for Client-Side Developers, which is actually a great article itself, it got me to question what libraries I had in my classpath, and whether or not that list was complete.

Turns out there was one file he listed that I didn’t have: hibernate-entitymanager.jar.

Looks important, eh?


I easily found a copy in the Hibernate Extensions at HibernateExt\tools\lib\testlibs.
There was also a copy in the Hibernate Tools at HibernateTools-3.2.0b9a\plugins\org.hibernate.exlipse_3.2.0.beta9a\lib\annotations.

Once I placed a copy in there, things worked great. So it’s not just the property file, but the .jar file that needs it.

0 thoughts on “Hibernate: No Persistance Provider”

  1. Dude, you are life saver. Thanks for letting me know about the hibernate-entitymanager,jar. This was exactly the solution that I was looking for. VERY annoying that no where in the documentation do it mention that you need this jar running hibernate standalone. Allow me to vent for a second. I’ve been doing java programming for 10+ years with some experience in Hibernate on few different projects. Last year I converted to Ruby on Rails and have been blown away by the productivity gains, the clean code and the ease of convention over configuration. I however am now back working on a standalone java app and decided to take another look at Hibernate with Annotations. Pretty cool, but still light years away from the ease of programming in dynamic language like Ruby or Groovy. Oh well, nice try guys with Hibernate and annotations. It is an improvement, but things like this, where I spend time pulling my hair out for hours and have to find some blog posting to get a solution is pretty darn annoying. If given the choice I’ll for sure use some other ORM instead of Hibernate. End rant. Thanks again Walt!

  2. From hibernate-entitymanager-3.2.0.CR1 I have;

    – hibernate-entitymanager-jar
    – hibernate-annotations.jar
    – ejb3-persistance.jar
    – jboss-archive-browsing.jar

    From hibernate 3.2 I have;

    – hibernate3.jar
    – dom4j-1.6.1.jar
    – commons-logging-1.0.4.jar
    – commons-collections-2.1.1.jar
    – cglib-2.1.3.jar
    – ehcache-1.2.jar
    – jta.jar
    – asm.jar
    – antlr-2.7.6.jar

    and hsqldb.jar
    add this tag org.hibernate.ejb.HibernatePersistence in your persistence.xml .Finally copy persistence.xml in META-INF folder. It will work .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.