3

当我运行我的 RCP 应用程序时,我收到错误消息:

Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named local
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)

我的类路径中有 eclipseLink 持久性 API 和 Derby JDBC 驱动程序的 jar 文件,并包含在我的 MANIFEST.MF 中:

Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.ui.forms;bundle-version="3.5.100",
 javax.servlet;bundle-version="2.5.0",
 com.caucho.hessian;bundle-version="3.0.8",
 org.apache.commons.lang;bundle-version="2.1.0",
 org.eclipse.persistence.core;bundle-version="2.4.0",
 org.eclipse.persistence.jpa;bundle-version="2.4.0",
 org.eclipse.persistence.asm;bundle-version="3.3.1",
 javax.persistence;bundle-version="2.0.4",
 workstation_dependencies;bundle-version="1.0.0", -- THIS IS A CUSTOM DEPS PACKAGE
 org.apache.derby;bundle-version="10.5.1"
Bundle-Vendor: MYVENDOR
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.20120319
Bundle-Name: MYBUNDLE
Bundle-Activator: foo.myrcpapp.Activator
Bundle-ManifestVersion: 2
Bundle-SymbolicName: foo.myrcpapp; 
 singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: com.caucho.hessian
JPA-PersistenceUnits: local
Meta-Persistence: META-INF/persistence.xml
Bundle-ClassPath: lib/commonj.sdo_2.1.1.v201112051852.jar,
 lib/commonj.sdo.source_2.1.1.v201112051852.jar,
 lib/derby-10.8.2.2.jar,
 lib/eclipselink-jpa-modelgen_2.4.0.v20120608-r11652.jar,
 lib/javax.activation_1.1.0.v201108011116.jar,
 lib/javax.ejb_3.1.0.v201205171433.jar,
 lib/javax.jms_1.1.0.v200906010428.jar,
 lib/javax.mail_1.4.0.v201005080615.jar,
 lib/javax.persistence_1.0.0.v200905011740.jar,
 lib/javax.persistence_2.0.4.v201112161009.jar,
 lib/javax.persistence.source_2.0.4.v201112161009.jar,
 lib/javax.resource_1.5.0.v200906010428.jar,
 lib/javax.servlet_2.4.0.v200806031604.jar,
 lib/javax.transaction_1.1.0.v201002051055.jar,
 lib/javax.ws.rs_1.1.1.v20101004-1200.jar,
 lib/javax.ws.rs.source_1.1.1.v20101004-1200.jar,
 lib/javax.wsdl_1.6.2.v201012040545.jar,
 lib/javax.xml.bind_2.2.0.v201105210648.jar,
 lib/javax.xml.bind.source_2.2.0.v201005080402.jar,
 lib/javax.xml.soap_1.3.0.v200906010428.jar,
 lib/javax.xml.stream_1.0.1.v201004272200.jar,
 lib/javax.xml.ws_2.0.0.v200902170419.jar,
 lib/org.eclipse.orbit.mongodb_2.7.3.v20120213-1927.jar,
 lib/org.eclipse.persistence.antlr_3.2.0.v201206041011.jar,
 lib/org.eclipse.persistence.antlr.source_3.2.0.v201206041011.jar,
 lib/org.eclipse.persistence.asm_3.3.1.v201206041142.jar,
 lib/org.eclipse.persistence.asm.source_3.3.1.v201206041142.jar,
 lib/org.eclipse.persistence.core_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.core.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.dbws_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.dbws.builder_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.dbws.builder.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.dbws.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.equinox_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.equinox.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.equinox.weaving_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.equinox.weaving.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.jpql_2.0.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.jpql.source_2.0.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.modelgen_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.modelgen.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.osgi_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.osgi.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpa.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpars_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.jpars.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.moxy_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.moxy.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.nosql_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.nosql.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.oracle_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.oracle.nosql_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.oracle.nosql.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.oracle.source_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.oracleddlparser_1.0.0.v20120530.jar,
 lib/org.eclipse.persistence.oracleddlparser.source_1.0.0.v20120530.jar,
 lib/org.eclipse.persistence.sdo_2.4.0.v20120608-r11652.jar,
 lib/org.eclipse.persistence.sdo.source_2.4.0.v20120608-r11652.jar,
 .

我的 persistence.xml 看起来像这样:

<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" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">

 <persistence-unit name="local" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

    <class>foo.Bar</class>

    <properties>
        <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:derby:mydb;create=true" />
        <property name="javax.persistence.jdbc.user" value="username" />
        <property name="javax.persistence.jdbc.password" value="passwd" />

        <property name="eclipselink.persistence-context.persist-on-commit" value="true"/>

        <!-- 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>
</persistence>

我尝试在persistence.xml 中放置随机乱码垃圾并得到相同的结果,所以我不确定它是否被拾取。persistence.xml 位于项目根目录的 META-INF 文件夹中,我尝试将 META-INF 文件夹复制到各个位置而没有任何更改。

有任何想法吗?

提前喝彩。

4

1 回答 1

0

这些例子可能会有所帮助,

http://wiki.eclipse.org/EclipseLink/Examples/OSGi

于 2012-09-24T13:56:18.753 回答