Marcin
Marcin

Reputation: 1276

No Persistence provider for EntityManager named with persistence file in correct spot

I've been searching around and haven't been able to find a working fix. My persistence.xml file is located in /src/META-INF/persistence.xml, which from looking around, this is the correct location for it.

I'm using glassfish as the server, and I keep getting the following:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named pers

Here is my persistence file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="pers" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>cs.ee.assignment2.Client</class>     

        <properties>
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.archive.autodetection" value="class, hbm" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/assignment2" />
            <property name="hibernate.connection.password" value="root" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        </properties>

    </persistence-unit>
</persistence>

Any ideas on what the problem could be would be greatly appreciated.

Upvotes: 0

Views: 342

Answers (1)

dbrin
dbrin

Reputation: 15673

Hmm.. make sure you are using PeristenceUnit not context in your entity class: see http://openejb.apache.org/jpa-concepts.html

Switch to "transaction" just to see if it fails too.

Also sometimes the old classes are not unloaded from the server properly if you are doing redeployment, you may have to shut it down and restart after redeploy.

Upvotes: 1

Related Questions