Mike3355
Mike3355

Reputation: 12081

cannot resolve org.apache.openjpa.persistence.PersistenceProviderImpl

I keep getting an error saying:

cannot resolve org.apache.openjpa.persistence.PersistenceProviderImpl

1

My jar file is there but I am having a hard time trying to figure out why I am still getting the error:

2

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">

    <persistence-unit name="dataBase">

        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <properties>
            <property name="openjpa.ConnectionURL" value="com.mysql.jdbc.Driver"/>
            <property name="openjpa.ConnectionDriverName" value="jdbc:mysql://localhost:8080/springpractice"/>
            <property name="openjpa.ConnectionUserName" value="root"/>
            <!--<property name="openjpa.ConnectionPassword" value=""/>-->
            <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO"/>
        </properties>

    </persistence-unit>
</persistence>

I have look all over google and the answer is not there. I double check to make sure the dependencies are not there twice in case there was a conflict. Because of this when I try to declare a @Entity it is not picking up the database tables.

Upvotes: 1

Views: 3697

Answers (3)

S. Pauk
S. Pauk

Reputation: 5318

You have to import a JPA implementation jar (OpenJPA in this case). You could get one from Maven Central or Apache OpenJPA home page itself.

UPDATED: as it has been mentioned in another ansewer it's better to remove the other JPA provider libraries (Hibernate).

Upvotes: 0

Mecon
Mecon

Reputation: 997

Based on the images of your lib directory, I would say you the XML definition for persistence-unit>provider is not as expected.

There are Hibernate Jars in your lib, so it seem like that "Persistence Provider" should be "Hibernate", and not "Apache OpenJPA".

If you really want to use Apache OpenJPA, then I would recommend removing Hibernate Jar files in your lib.

Hibernate is more popular of the two, so I would recommend it.

Upvotes: 1

Mike3355
Mike3355

Reputation: 12081

I had to add the following jar:

org.apache.openjpa:com.springsource.org.apache.openjpa.persistence:1.02

I trusted my IDE to much that it would download all the jars that I needed.

Upvotes: 0

Related Questions