views:

244

answers:

3

Hi everybody,

I'd like to create one Bundle that is able to use Java Persistence. To achieve this, I've created a plugin project within Eclipse. In my project, I've created a persistence.xml file into META-INF. I've aslo added in my MANIFEST.mf (into the depencies) those 3 packages :

  1. javax.persistence.jar
  2. org.eclipse.persistence.jar
  3. org.eclipse.persistence.jar

Then, in my Activator I use this lines to create an EntityManager :

factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME); EntityManager em = factory.createEntityManager();

To execute my bundle, I've made a product configuration. When I run my product configuration, I got this error : javax.persistence.PersistenceException: No Persistence provider for EntityManager named people

I've tried to move the location of my persistence.xml withtout succes. It seems that any package load the persistence.xml file. Maybe, I don't import the right packages?

You can download my simple Bundle here : download

Could you help me to find a solution or a clue?

Thanks you very much,

Bat

+1  A: 

Try adding this tag in the persistence.xml:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Bozho
Thanks, but I've this line in my persistence.xml file.Another solution?
+1  A: 

Hi,

It seems that you did not describe your persistence unit in MANIFEST.MF with JPA-PersistenceUnits: header. You can find more details for EclipseLink here (1)

(1): http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Developing_with_EclipseLink_OSGi_in_PDE

Cheers, Dmytro

Dmytro Pishchukhin
I've solved my problem. I only had to put in the classpath of the manifest this packages : - persistence.jar - eclipselink.jar - mysql-connector.jarThanks
A: 

I've solved my problem. I only had to put in the classpath of the manifest this packages : - persistence.jar - eclipselink.jar - mysql-connector.jar

Thanks