Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Create symphonies in seed and soil. For 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