This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JPA javax.persistence.PersistenceException: No Persistence provider for EntityManager

 
Greenhorn
Posts: 5
Eclipse IDE Oracle Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day Cowboys and Cowgirls,

I'm studying for my OCEJPA and going trough the book Pro Jpa 2 (based on the JPA 2.0 spec not the 2.1 spec).

And well I am walking against a small wall. I'm just fiddling with the examples and just try to make them my own, and most of the code I think is ok and I think i'm doing something wrong in my Eclipse ocnfiguration or in Maven. Let me go a bit more in detail.

I decided to make my own small application based on the example code in chapter 2 thinking ok this i not complex etc. I have a few alterations of course (not using the same objects for starters) but also made it a Maven project bc i'm also trying to get that in my fingers. However I can do a mvn clean install all I want and try to run the project. I keep running against the

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ConventionService
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at ConvenionTest.main(ConvenionTest.java:11)

Error. And I'm thinking or i'm doing something really simple wrong. Or im forgetting somting.

So here is is my project structure:

(or you can find it here: http://imagebin.org/index.php?mode=image&id=271976)

Here is my persistence.xml code:



My entety object Convention :


My ConventionService



And here is a snipet of my test code:


IM quite sure its not the code (or at least I think so) please tell me where I go wrong if needed I can also post the pom.xml.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your persistence.xml file:

You need to uncomment line 8 to specify the persistence provider you wish to use.

P.S. I think you have posted your Convention class twice by accident.
 
Martijn Cremer
Greenhorn
Posts: 5
Eclipse IDE Oracle Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks James for the quick reply, I added line 8 on some searching but did not work. In the JPA 2 book it does not have the <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> tag.

Still tried it real quick and still got error:

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ConventionService
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at ConvenionTest.main(ConvenionTest.java:11)


And yes I miss copy paste ill fix that right away.
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it like this:i.e. The provider element above the class element (as specified in persistence_2_0.xsd)

Also, make sure the class org.eclipse.persistence.jpa.PersistenceProvider in on your classpath. I think it is usually bundled in the jar file eclipselink.jar.
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic