引发者:javax.persistence.PersistenceException:没有名为local的EntityManager的持久性提供程序

时间:2012-09-22 16:03:58

标签: jpa eclipse-rcp eclipselink derby

当我运行我的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文件夹复制到各个位置而不做任何更改。

有什么想法吗?

提前干杯。

1 个答案:

答案 0 :(得分:0)

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

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