OSGI中的EclipseLink错误没有名为EntityManager的持久性提供程序

时间:2014-08-06 22:41:33

标签: jpa osgi eclipselink rcp

我有一个使用Gemini JPA(v1.2.0)和EclipseLink(v2.5.2)的RCP 3.7应用程序(Equinox OSGI)。我无法在Manifest.MF中获得Require-Bundle的正确组合来读取persistence.xml。有没有人有他们可以分享的工作MANIFEST.MF?

我发现的所有其他问题都提到了旧版本的EclipseLink和不在发行版中的Eclipselink.jar。我在Gemini JPA上阅读了文档,但没有找到它。

基于其他帖子我也

  • 在startLevel = 3时将org.eclipse.gemini.jpa添加到autoStart = true
  • 将我的包含persistence.xml的软件包添加到默认情况下的autoStart = true
  • 添加了VM参数-DREFRESH_BUNDLES = false

感谢您抽出宝贵时间阅读我的问题!

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> 

2 个答案:

答案 0 :(得分:0)

他们有几个问题需要解决。

  1. 无数据库提供程序 - 将Gemini DBAccess添加到项目
  2. 加载了错误的PersistenceProviderResolver - 正在加载静态内部类而不是OSGiProviderResolver。由#4解决。
  3. DS和JPA中的循环导致多个异常 - 添加了VM参数-DREFRESH_BUNDLES = false
  4. 需要将Bundles配置为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(如果使用)

答案 1 :(得分:0)

我想纠正几点:

  1. 没有org.eclipse.gemini.dbutil,而是org.eclipse.gemini.dbaccess.util

  2. Eclipse Gemini JPA的最新版本是1.2.0.M1,因此org.eclipse.gemini.jpa;bundle-version="1.2.0"对我不起作用。

  3. 这个 MANIFEST.MF 适合我:

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-SymbolicName: org.openhab.binding.mybinding;singleton:=true
    Bundle-Name: org.openhab.binding.mybinding
    Bundle-Version: 1.0.0.qualifier
    Bundle-RequiredExecutionEnvironment: JavaSE-1.8
    Meta-Persistence: META-INF/persistence.xml
    Import-Package: com.fasterxml.jackson.annotation,
     com.fasterxml.jackson.core,
     com.fasterxml.jackson.databind,
     javax.persistence,
     javax.servlet.http,
     javax.ws.rs.client,
     javax.ws.rs.core,
     org.eclipse.jetty.io,
     org.eclipse.jetty.server,
     org.eclipse.jetty.server.handler,
     org.eclipse.jetty.servlet,
     org.eclipse.jetty.util.component,
     org.eclipse.jetty.websocket.api,
     org.eclipse.jetty.websocket.api.annotations,
     org.eclipse.jetty.websocket.client,
     org.eclipse.jetty.websocket.common,
     org.eclipse.jetty.websocket.servlet,
     org.eclipse.paho.client.mqttv3,
     org.eclipse.paho.client.mqttv3.persist,
     org.eclipse.smarthome.config.core,
     org.eclipse.smarthome.core.library.types,
     org.eclipse.smarthome.core.thing,
     org.eclipse.smarthome.core.thing.binding,
     org.eclipse.smarthome.core.types,
     org.glassfish.hk2.osgiresourcelocator,
     org.glassfish.jersey,
     org.glassfish.jersey.client,
     org.glassfish.jersey.jackson,
     org.slf4j,
     org.testng,
     org.testng.annotations,
     com.google.common.collect
    Require-Bundle: org.eclipse.gemini.jpa,
     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/*.xml
    

    这是我的 persistence.xml

        <persistence-unit name="supervisor-state" transaction-type="RESOURCE_LOCAL">
            <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    
            <class>com.gadgetkeeper.hub.supervisor.model.ActivationInfo</class>
            <class>com.gadgetkeeper.hub.supervisor.model.SupervisorState</class>
            <class>com.gadgetkeeper.hub.supervisor.model.Version</class>
    
            <properties>
                <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
                <property name="javax.persistence.jdbc.url"
                          value="jdbc:derby:db/supervisordb;create=true"/>
                <property name="javax.persistence.jdbc.user" value="supervisor"/>
                <property name="javax.persistence.jdbc.password" value="supervisor"/>
    
                <!-- EclipseLink should create the database schema automatically -->
                <property name="eclipselink.ddl-generation" value="create-tables"/>
                <property name="eclipselink.ddl-generation.output-mode"
                          value="database"/>
            </properties>
        </persistence-unit>