aspose file tools*
The moose likes Object Relational Mapping and the fly likes JPA  javax.persistence.PersistenceException: No Persistence provider for EntityManager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA  javax.persistence.PersistenceException: No Persistence provider for EntityManager" Watch "JPA  javax.persistence.PersistenceException: No Persistence provider for EntityManager" New topic
Author

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

Martijn Cremer
Greenhorn

Joined: Jul 05, 2013
Posts: 5

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.


Last night I stayed up late playing poker with Tarot cards. I got a full house and four people died.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

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

Joined: Jul 05, 2013
Posts: 5

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

Joined: Nov 09, 2011
Posts: 1030
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA javax.persistence.PersistenceException: No Persistence provider for EntityManager