• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA: Can't find Persistence Provider

 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working through the examples in the book "Java Persistence with Hibernate". I've created a JPA probject as a Java project in Eclipse with all the necessary dependencies set up.

According to the book, one should be able to place a persistence.xml file in the META-INF directory of the classes root directory and have the Persistence class find it when it's time to build the EntityManager. However, this just does not seem to work for me. Any ideas? Below is my code:

persistence.xml in META-INF


When I try to exeute the statement:

I get the error:
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named helloworld

I'm running this from Eclipse.
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried to specify a <provider> element for your persistence unit?
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Merrill,

In the persistence schema definition, you have the
<provider> element which indicates what persitence provider to use the DAO.
For instance:

to tell it you use Hibernate as the persistence framework.

That'all
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies. I did try adding the <provider> stanza, but unfortunately, it didn't help. This problem appears to have something to do with the way applications are run inside Eclipse, because when I download the solution code and run it from an ANT task, it works fine.
 
Pierre Henry
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,

Can you send a stack trace to see the origin of the problem?
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
Thanks for your replies. I did try adding the <provider> stanza, but unfortunately, it didn't help. This problem appears to have something to do with the way applications are run inside Eclipse, because when I download the solution code and run it from an ANT task, it works fine.



To run it from within Eclipse, you might have to place the META-INF/persistence.xml file at the root of the source (or src) directory.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have exactly same problem. How could you solve your problem.
Thanks.
 
Ranch Hand
Posts: 183
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had this as well.
It is because I had forgotten to place the hibernate-entitymanager.jar into my lib directory. Then when Persistence tries to find any persistence-providers on the classpath, it was not finding any at all.
Cheers, Neil
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,


i try add a java project to use JPA persistance (not dynamic web application) i add the jar file for the entity manager but still get the same problem
here is my configrations and class files


this is the persistence.xml file under the "src" directory



and the entity class manager :




and the DAO book class




and about the Book Entity class



when i run the following test code as java application i get the same error :


best regards
 
reply
    Bookmark Topic Watch Topic
  • New Topic