I'm trying to persist elements using JPA and EclipseLink. So I've created a class to persist
@Entity
public class Couple implements Serializable{
private static final long serialVersionUID = 1L;
@Column(name = "OBJECTID")
private String objectID;
@Column(name = "EPCNUMBER")
private String epcNumber;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
And so on. I've created a class to "use" that :
public class Main {
private static final String PERSISTENCE_UNIT_NAME = "MyPU";
private static EntityManagerFactory factory;
public static void main(String[] args) {
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();
TypedQuery<Couple> q = em.createQuery("SELECT c FROM Couple c", Couple.class);
List<Couple> couples = (List<Couple>) q.getResultList();
And then, i've the following persistence.xml :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="MyPU">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>localJTA</jta-data-source>
<class>fr.mypackage.com.Couple</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO"/>
</properties>
</persistence-unit>
</persistence>
But, even when I change the properties, I've got the same error :
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyPU (when calling factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);).
Did I do something wrong to ling xml and persistence unit ? I've weel added to classpath the following :
javax.persistence.jar
javax.ejb.jar
eclipselink.jar
javax.persistence_1.0.0.jar
javax.persistence_2.0.4.v201112161009.jar
derby.jar
Could you help me ? Thanks !