I know this has been asked a lot on SO, but they don't offer solutions to my problem:
I'm using a project with JPA, cloned from someone else with the exact same settings (same OS, same IDE, same database name, also in MAMP)
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistentie
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at DatabaseTest.main(DatabaseTest.java:29)
My persistence.xml (both in folder /META-INF/ and /WEB-INF/classes/META-INF/, as suggested on multiple other questions on SO):
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="persistentie" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>Domein.Student</class>
<class>Domein.Onderzoeksdomein</class>
<class>Domein.Promotor</class>
<class>Domein.Gebruiker</class>
<class>Domein.Campus</class>
<class>Domein.Presentatie</class>
<class>Domein.Dag</class>
<class>Domein.Lokaal</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/Project2-DB?zeroDateTimeBehavior=convertToNull"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
This line is where it gets the Exception:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistentie");
There's no code before this, it's the first line of the main.
I'm using MAMP, NetBeans 7.4 with Persistence (JPA 2.1)
and OS X.
I'm completely lost here... As I didn't change anything from my friend's code, this should work right?
Also I checked out the source of javax.persistence.Persistence.createEntityManagerFactory(String name) and I found that resolver.getPersistenceProviders() returns an empty List. I don't have the experience in JPA to know what this means though.
You haven't EM
jar in your classpath. Simply add this :
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>