2

everyone. I'm new to JPA 2.0. I'm using maven and eclipse, as well as eclipse link. I have this in my 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="certifications">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStg</class>
        <class>com.ni.apps.engineering.certification.entities.NicdsCliCertificationStgPK</class>
        <class>com.ni.apps.engineering.certification.entities.NicdsCliUpMapping</class> 
        <exclude-unlisted-classes>false</exclude-unlisted-classes>          
        <properties>            
            <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:5455:orcl"/>
            <property name="javax.persistence.jdbc.password" value="ni"/>
            <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
            <property name="javax.persistence.jdbc.user" value="NI"/>
            <property name="eclipselink.logging.level.sql" value="FINE"/>
        </properties>       
    </persistence-unit>
</persistence>

And I have this code in a facade to get the entity manager.

private EntityManagerFactory emf;

protected EntityManager getEntityManager(){
    if(emf == null){
        emf = Persistence.createEntityManagerFactory("certifications");
    }
    return emf.createEntityManager();
}

When I get to this part, it always returns "No persistence provider for EntityManager named certifications". I made sure that the persistence.xml is in the META-INF and the META-INF is part of the classpath. Any ideas? Thanks!!

--EDIT-- Stacktrace added

Exception in thread "main" com.ni.apps.engineering.certification.exception.CertificationException: Internal Server Error
    at com.ni.apps.engineering.certification.controller.AbstractFacade.getContactIdByUpId(AbstractFacade.java:28)
    at com.ni.apps.engineering.certification.controller.CertificationFacade.getCertificationsByUpId(CertificationFacade.java:14)
    at com.ni.apps.engineering.certification.dao.CertificationDAO.getCertificationByUpId(CertificationDAO.java:13)
    at Main.main(Main.java:9)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named certifications
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at com.ni.apps.engineering.certification.controller.AbstractFacade.getEntityManager(AbstractFacade.java:17)
    at com.ni.apps.engineering.certification.controller.AbstractFacade.getContactIdByUpId(AbstractFacade.java:25)
Nacho321
  • 1,911
  • 7
  • 33
  • 55
  • can you please post stacktrace – Adi Aug 21 '14 at 17:36
  • do you have org.eclipse.persistence.jpa.jar also in your classpath? – Manjunath Aug 21 '14 at 17:45
  • Since I use maven, I believe it's added automatically to the classpath. I'm checking the imports, and it says that it added javax.persistence_2.0.0.v01002051058.jar. Is it the same? – Nacho321 Aug 21 '14 at 18:42
  • Ok, I checked the eclipselink wiki (http://wiki.eclipse.org/EclipseLink/Maven) and it says that adding to maven the eclipselink dependency should add all eclipselink artifacts, including org.eclipse.persistence.jpa – Nacho321 Aug 21 '14 at 18:44
  • What artifacts are you pulling and ohow have you configured it? You need org.eclipse.persistence.jpa and org.eclipse.persistence.core. javax.persistence_2.0.0.v01002051058.jar contains only the java.persistence JPA interface classes. – Chris Aug 22 '14 at 02:56
  • You need eclipselink.2.x.x.jar – Ye Wint Sep 19 '14 at 05:15
  • I dont have eclipseLink, but openjpa and the path to persistence.xml is configured in pom in plugin section, maybe it will help you or you can post your pom configuration, if you have – Zavael Sep 29 '14 at 20:18

0 Answers0