This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
Joined: Dec 12, 2012
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?
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.
Joined: Dec 12, 2012
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:
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.