wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Trying to run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Trying to run "hello world" JPA app with Maven: No Persistence provider for EntityManager" Watch "Trying to run "hello world" JPA app with Maven: No Persistence provider for EntityManager" New topic
Author

Trying to run "hello world" JPA app with Maven: No Persistence provider for EntityManager

Anton Reshetnikov
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Hello,

I'm learning JEE6 and Maven. I'm trying to resolve this issue for two days already with no success, so maybe someone could help me here? The thing is, I can't run a hello world app, that uses JPA. Here's what I do and what I get:



Build successful, no issues. Then:



Note the message "No Persistence provider for EntityManager named jeetest" at line 22. The persistence.xml file is located in my src/main/resources/META-INF and it's being correctly copied by Maven to target/classes/META-INF. Here is the persistence.xml:



The database is also up and running. And here is the pom.xml:



Maybe I should add a dependency for that org.eclipse.persistence.jpa.PersistenceProvider? But I don't know the groupId, artifactId and version for it. I guess my mistake is stupid, but I'm stuck on it. Please, give me a clue.

Thank you!
Anton Reshetnikov
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Oh, yes. And this the line where the exception occurs in my java code:

Still have no idea what am I doing wrong. When I use 'maven exec', does it automatically include dependecy jars from the pom.xml to the java CLASSPATH?
Danil TuchkoFf
Greenhorn

Joined: Dec 11, 2012
Posts: 3
Probably, maven not downloaded dependencies. You need EclipseLink runtime(persistence provider), that defined in the eclipselink artifactId, you have it in pom.xml. First, remove <repository>with id eclipselink. add the following in pom.xml

After that, instead of mvn exec, run mvn assembly:single. This command should create complete jar file with dependencies, creates Manifest with main class. And you can see all needed dependencies in that jar, and can execute it with java -jar youjar.jar.

Anton Reshetnikov
Greenhorn

Joined: Dec 12, 2012
Posts: 3
Hi! Thanks a lot for your reply. I did what you told me, and here is the info I got from this investigation.
First of all, Maven fetches all the dependencies correctly, they are in my local repository. Anyway, I tried use the assembly plugin. Deleting eclipselink repository from pom.xml resulted in error while compiling, though. So I left it undeleted and compiled my code:



Good. Then:



So now I have the jar with all dependencies included, so I run it:



The same error! Now it's clear that it's not a classpath or missing jars issue. May there is a mistake in persistence.xml or pom.xml? But persistence.xml gets copied to the jar by Maven! I don't know what to think.
I would be very grateful if someone points me on my mistake.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to run "hello world" JPA app with Maven: No Persistence provider for EntityManager
 
Similar Threads
The POM for org.eclipse.persistence:eclipselink:jar:2.3.0 is missing
Maven not downloading dependency for org.eclipse.persistence
Richfaces + Spring + Maven Setup help
Maven dependencies
Error slf4j-api, I can't exclude slf4j-api for Jboss