persistence provider not found
hi,
I use IntelliJ IDEA 10.5 Ultimate. I'm trying to persist using JPA with EclipseLink as persistence provider.
When I run my main class I get the following error:
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named chapter02PU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:84)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.apress.javaee6.chapter02.Main.main(Main.java:20)
...
I have enabled JPA support according to the IntelliJ help.
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="chapter02PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.apress.javaee6.chapter02.Book</class>
<properties>
<property name="eclipselink.target-database" value="DERBY"/>
<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="eclipselink.jdbc.url" value="jdbc:derby://localhost:1527/chapter02DB;create=true"/>
<property name="eclipselink.jdbc.user" value="APP"/>
<property name="eclipselink.jdbc.password" value="APP"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
My facet configuration:
<component name="FacetManager">
<facet type="jpa" name="JPA">
<configuration>
<setting name="validation-enabled" value="true" />
<setting name="provider-name" value="EclipseLink" />
<datasource-mapping>
<factory-entry name="chapter02PU" />
</datasource-mapping>
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/META-INF/persistence.xml" />
</configuration>
</facet>
</component>
My project is a Maven module and I've configured my pom.xml to download the (in my opinion necessary) jar files:
javax.persistence (1.1.0),
eclipselink (1.1.0)
derbyclient (10.4.2.0)
derby (10.4.2.0)
The corresponding jar files are now listed as external libraries.
However IntelliJ's JPA support still complained about a missing javax.persistence jar, so I clicked "fix" and now have a javax.persistence.jar in the "lib" folder of the project, too.
The line, IntelliJ is referring to (in the error infos) is:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("chapter02PU");
I've found a thread in this forum adressing the same problem (http://devnet.jetbrains.net/message/5302381#5302381).
That thread's founder said he had to add some jars to the application server library. However I don't know whether this should
also help me, as I think I let Maven import all necessary jars.
I really have no more idea how to fix this problem.
Please sign in to leave a comment.
Hi.
Can you start your pesrsistence provider at all (not using JPA console)? For me the probable reason is either driver abseny on classpath either persistence.xml is in incorrect place
regards, Alex
Message was edited by: Alexander Ashitkin
How do I find out, if I can start the persistence provider at all?
I thought I can only start it by executing my main.
The persistence.xml is located in the META-INF directory at project root.
I've attached my project to this answer.
Attachment(s):
Test1.zip
Hi, Richard.
I see at least 2 problems in your project - eclipselink dependencies couldn't be retrieved from maven repository (you have to put eclipse maven repo it in the pom) and META-INF is in the wrong place (move it under src/main/resources).So, jpa setup isn't runnable itself.
I hope you took a look at eclipslink and JPA docs to figure out what to do:
http://wiki.eclipse.org/EclipseLink/Maven
http://download.oracle.com/docs/cd/B31017_01/web.1013/b28221/pkgapp001.htm
http://wiki.eclipse.org/Packaging_and_Deploying_EclipseLink_JPA_Applications_%28ELUG%29
apress.com rulezzz :)
best regads, Alex
Hi Richard Schubert
I'm Stefan. I have the same problem like you, but I am using the hibernate impl for JPA.
I always get this message No persistence unit with name 'persistenceUnit found during tomcat startup.
My persistence.xml is in the META-INF (actually where its supposed to be and not in the resource folders).
How did solve your problem?
Regards
Stefan
PS
Just in case, i created a screen cast
cheers