Search code examples
jpaosgieclipselinkrcp

EclipseLink in OSGI Error No Persistence provider for EntityManager named


I have an RCP 3.7 application (Equinox OSGI) using Gemini JPA (v1.2.0) and EclipseLink (v2.5.2). I can't get the right combination of Require-Bundle in Manifest.MF to read the persistence.xml. Does anyone have the a working MANIFEST.MF they can share?

All the other questions I found referred to older versions of EclipseLink and an Eclipselink.jar that is not in the distribution. I read the documentation at Gemini JPA but did not find it specified.

Based on other posts I have also

  • Added org.eclipse.gemini.jpa to autoStart=true at startLevel = 3
  • Added my bundle with persistence.xml to autoStart=true at default
  • Added VM argument -DREFRESH_BUNDLES=false

Thanks for taking the time to read my question!

MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Meta-Persistence: META-INF/persistence.xml
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
Bundle-Name: Local
Bundle-SymbolicName: com.vogelware.simple.local
Bundle-Version: 0.1.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.vogelware.simple.model,
 com.vogelware.simple.service,
 javax.persistence;version="2.1.0",
 org.osgi.service.component;version="1.1.0"
Require-Bundle: org.eclipse.gemini.jpa;bundle-version="1.2.0",
 org.eclipse.persistence.antlr;bundle-version="3.2.0",
 org.eclipse.persistence.asm;bundle-version="3.3.1",
 org.eclipse.persistence.core;bundle-version="2.5.2",
 org.eclipse.persistence.jpa;bundle-version="2.5.2",
 org.apache.derby;bundle-version="10.8.2"
Service-Component: OSGI-INF/PersonEntityService-local.xml
Bundle-ActivationPolicy: lazy

persistence.xml

<?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="person" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <class>com.vogelware.simple.Person</class>

        <properties>
            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:derby:D:\dev\projects\EASA-DB\motordb" />
        </properties>
    </persistence-unit>
</persistence> 

Solution

  • Their were several issues that needed to be resolved.

    1. No DB provider - Add Gemini DBAccess to project
    2. Wrong PersistenceProviderResolver loaded - the static inner class was being loaded instead of OSGiProviderResolver. Solved by #4 below.
    3. Cycles in DS and JPA resulting in multiple Exceptions - Added VM argument -DREFRESH_BUNDLES=false
    4. Bundles needed to be configured to autoStart="true" startLevel="3"
      • javax.persistence
      • org.apache.derby
      • org.eclipse.gemini.dbaccess.derby
      • org.eclipse.gemini.dbutil
      • org.eclipse.gemini.jpa
      • org.eclipse.gemini.blueprint (if used)