7

我目前在 Felix (v4.0.3) 上开发一个 OSGi 项目。我需要使用 JPA,所以我安装了 Apache Aries JPA 包。我还安装了 OpenJPA,我需要它来使用 MySQL 连接器包连接到 MySQL 数据库。不幸的是它不起作用,OpenJPA 说它找不到 MySQL JDBC 类,我无法弄清楚是什么坏了,也许我做错了什么。我将在下面解释我精确安装的内容以及 persistence.xml 文件和我得到的实际异常。

这是我安装的 Apache Aries 捆绑包的列表:

  1. org.apache.aries.jpa.api-0.3.jar
  2. org.apache.aries.jpa.container.context-0.3.jar
  3. org.apache.aries.jpa.container-0.3.jar
  4. org.apache.aries.util-0.4.jar

然后我安装了那些 Apache Aries JPA 包的依赖项。我从 Springsource 下载了它们:

  1. com.springsource.javax.transaction-1.1.0.jar
  2. com.springsource.org.apache.log4j-1.2.16.jar
  3. com.springsource.slf4j.api-1.6.1.jar
  4. com.springsource.slf4j.log4j-1.6.1.jar
  5. javax.persistence_2.0.4.v201112161009.jar(这个来自 EclipseLink,以防万一)

我还安装了 OpenJPA 及其所有依赖项。我在apache-openjpa-2.2.0下载文件夹的lib文件夹中找到了 bundle 2 到 5 (commons-*) 。我在这里下载了 Serp ,因为在 lib 文件夹中找到的 jar 不是 OSGi 包。最后我在 Springsource 中找到了最后两个包(#7 和 #8):

  1. openjpa-2.2.0.jar
  2. commons-collections-3.2.1.jar
  3. commons-dbcp-1.4.jar
  4. commons-lang-2.4.jar
  5. commons-pool-1.5.4.jar
  6. org.apache.servicemix.bundles.serp-1.13.1_4.jar
  7. com.springsource.javax.servlet-2.5.0.jar
  8. com.springsource.org.objectweb.asm-3.2.0.jar

一旦我最终安装了 OpenJPA,我仍然需要 MySQL JDBC 驱动程序包,我也从 Springsource 存储库中获得了它以及它的 commons-logging 依赖项:

  1. com.springsource.com.mysql.jdbc-5.1.6.jar
  2. com.springsource.org.apache.commons.logging-1.1.1.jar

现在,安装的捆绑包列表变得非常大。我说我安装了 OpenJPA,但这只是因为我不知道如何将任何其他提供程序与 Aries 一起使用。我最初想使用 EclipseLink,但显然 Apache Aries 没有将其检测为提供程序,并且根据此博客,您必须制作另一个包含您自己的激活器的捆绑包,以便 Aries 注意到 EclipseLink。我试过了,但没有用,所以我改用 OpenJPA。

所以现在我有两个问题:

  • 如何让 OpenJPA 注意到我的 MySQL Bundle?

或者:

  • 如何让 Apache Aries 注意到 EclipseLink ?

这是我使用的 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="userManager.model" transaction-type="RESOURCE_LOCAL">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>org.project.dao.entity.UserEntity</class>
    <properties>
        <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
        <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/usermanager?autoReconnect=true" />
        <property name="openjpa.ConnectionUserName" value="root" />
        <property name="openjpa.ConnectionPassword" value="root" />            
    </properties>
</persistence-unit>
</persistence>

执行我的 DAO 类的以下构造函数时发生错误:

    @PersistenceContext(unitName="userManager.model")
private EntityManager em;
private EntityManagerFactory emf;

public UserDAOBean() {
    em = emf.createEntityManager();
}

这是我在 OpenJPA 找不到 MySQL 时遇到的错误。当然值得一提的是 URL 和用户名/密码都可以工作:

<openjpa-2.2.0-r422266:1244990 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: There were errors initializing your configuration: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.util.UserException: A connection could not be obtained for driver class "com.mysql.jdbc.Driver" and URL "jdbc:mysql://localhost:3306/usermanager?autoReconnect=true".  You may have specified an invalid URL.
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newConnectException(DataSourceFactory.java:255)
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:123)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:732)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:295)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1671)
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:646)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
at org.apache.aries.jpa.container.impl.CountingEntityManagerFactory.createEntityManager(CountingEntityManagerFactory.java:64)
at javax.persistence.EntityManagerFactory$$Proxy.createEntityManager(Unknown Source)

我已经消除了异常(它一直在继续)直到这一点:

Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found by org.apache.openjpa [12]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:85)
... 108 more

PS:由于垃圾邮件限制,我无法发布指向 Aries、OpenJPA 或 EclipseLink 的链接,抱歉:/

4

3 回答 3

4

感谢 Holly Cummins,经过几个小时的研究,我找到了解决问题的方法。我将在下面详细说明,这将是一个很长的答案。

如果您想将EclipseLink与 Apache Aries 一起使用(我发现安装它比 OSGi 的 OpenJPA 简单几个数量级,因为它只包含在5个捆绑包中),您必须直接从 apache 签出 EclipseLink - Aries 适配器,因为它还没有尚未发布。

转到适当的文件夹并执行以下命令来获取它:

svn checkout https://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-eclipselink-adapter/

您应该得到一个名为jpa-container-eclipselink-adapter的文件夹。现在,假设您使用的是 Linux 并安装了 Maven,请运行以下命令:

cd jpa-container-eclipselink-adapter
mvn clean install

一旦 Maven 成功编译了适配器的源代码,您将使用路径在 Maven 存储库中找到它

<maven-repo>/org/apache/aries/jpa/org.apache.aries.jpa.eclipselink.adapter/0.3.1-SNAPSHOT/org.apache.aries.jpa.eclipselink.adapter-0.3.1-SNAPSHOT.jar

您必须与其他捆绑包一起部署此捆绑包(将其复制到 Felix 的捆绑包文件夹中)。

这就是 EclipseLink 部分,现在为了让您的持久性真正发挥作用,您必须将 Blueprint 与 Aries 一起使用。这是您需要从 [http://aries.apache.org/downloads/currentrelease.html](Apache Aries 下载页面)获取的所有捆绑包的列表

  1. org.apache.aries.blueprint
  2. org.apache.aries.proxy
  3. org.apache.aries.jndi.api
  4. org.apache.aries.jndi
  5. org.apache.aries.blueprint
  6. org.apache.aries.jpa.api
  7. org.apache.aries.jpa.container.context
  8. org.apache.aries.jpa.container
  9. org.apache.aries.transaction.blueprint
  10. org.apache.aries.transaction.manager(这个在他们的网站上列出了两次,只是重复)
  11. org.apache.aries.util

完成 Aries 下载后,您仍然需要依赖项(从 SpringSource 获取它们)。这些是 SLF4J、Log4J、SLF4J Log4J Binding 和 javax.transaction 1.1 API 的捆绑包。

  1. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.slf4j.api&version=1.6.1
  2. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.slf4j.log4j&version=1.6.1
  3. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.javax.transaction&version=1.1.0
  4. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.log4j&version=1.2.16

您还需要来自 EclipseLink 的包(您需要 OSGi 包版本)

http://www.eclipse.org/eclipselink/downloads/

打开 zip 并获取以下文件:

  1. org.eclipse.persistence.antlr
  2. org.eclipse.persistence.asm
  3. org.eclipse.persistence.core
  4. org.eclipse.persistence.jpa
  5. javax.persistence

最后,假设您要使用 MySQL 数据库,您将需要 MySQL JDBC 驱动程序包(从 Springsource 下载)

  1. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.com.mysql.jdbc&version=5.1.6
  2. http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.commons.logging&version=1.1.1

一旦你安装了所有这些包,你需要使用一个你将通过 JNDI 获得的非 jta 数据源。这是一个 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="userManager" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/userManagerDS)</non-jta-data-source>
        <class>com.example.dao.entity.UserEntity</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>  
            <!-- 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>

看到非 jta-data-source 标记中的javax.sql.Datasource了吗?这就是我们将使用 Blueprint xml 定义的内容。为此,您首先需要在持久性捆绑包中添加OSGI-INF/blueprint/文件夹(包含您的 DAO 和实体的那个)。这是蓝图 xml 文件所在的默认文件夹,位于此处的任何 xml 文件都将被扫描。完成后,创建blueprint.xml文件(名称可以更改)并粘贴(和修改)以下代码:

        <bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <property name="url" value="jdbc:mysql://localhost:3306/usermanager?autoReconnect=true" />
        <property name="user" value="root" />
        <property name="password" value="root" />
    </bean>

    <service id="MySQLDataSource" interface="javax.sql.DataSource" ref="dataSource">
        <service-properties>
            <entry key="osgi.jndi.service.name" value="jdbc/userManagerDS" />
        </service-properties>
    </service>

    <service id="userDAOService" interface="com.example.dao.remote.UserDAORemote">
        <bean class="com.example.dao.beans.UserDAOBean">
            <jpa:unit index="0" unitname="userManager" />
        </bean>
    </service>
</blueprint>

在这里,我们正在做两件事。首先,我们告诉 Aries 创建userManagerDS数据源并使用 JDBC 驱动程序、URL、用户和密码对其进行配置。这与我们在persistence.xml文件中使用的数据源相同。

然后,我们在 DAO 中注入EntityManagerFactory。我们的 DAO 是com.example.dao.beans.UserDAOBean类,我们需要将其名称添加到bean标记中。这个类必须实现一个接口,我们需要将此接口添加到服务标签中。现在,最后的jpa:unit标记告诉 Aries 使用 UserDAOBean 的第一个构造函数注入与名为userManager(我们在 persistence.xml 中使用的名称相同)的持久性单元相关的 EntityManagerFactory。这是通过使用 index="0" 属性来完成的。这也意味着你的 DAO 中必须有如下代码:

private EntityManager em;
private EntityManagerFactory emf;

public UserDAOBean(EntityManagerFactory emf) {
    this.emf = emf;
    this.em = emf.createEntityManager();
}

也可以使用 setter 注入 EMF。以下是帮助您使用 Blueprint 的更多资源:

可选:请注意,如果您使用的是 Felix,添加 javax.transaction 包将导致“违反使用约束”,因为系统包(包 0)也导出此 API。您必须通过更改config.properties中的以下行来阻止它导出它:

#org.osgi.framework.system.packages=

您必须在此处输入上一个包导出的所有包的列表。不幸的是,没有办法“删除”一个包,您必须重新定义要导出的整个包列表。这是我的,我希望它有帮助(是的,它非常非常长):

org.osgi.framework.system.packages=org.osgi.framework;version=1.6.0, org.osgi.framework.launch;version=1.0.0, org.osgi.framework.wiring;version=1.0.0, org.osgi.framework.startlevel;version=1.0.0, org.osgi.framework.hooks.bundle;version=1.0.0, org.osgi.framework.hooks.resolver;version=1.0.0, org.osgi.framework.hooks.service;version=1.1.0, org.osgi.framework.hooks.weaving;version=1.0.0, org.osgi.service.packageadmin;version=1.2.0, org.osgi.service.startlevel;version=1.1.0, org.osgi.service.url;version=1.0.0, org.osgi.util.tracker;version=1.5.0, javax.accessibility;version=0.0.0.1_006_JavaSE, javax.activation;version=0.0.0.1_006_JavaSE, javax.activity;version=0.0.0.1_006_JavaSE, javax.annotation.processing;version=0.0.0.1_006_JavaSE, javax.annotation;version=0.0.0.1_006_JavaSE, javax.crypto.interfaces;version=0.0.0.1_006_JavaSE, javax.crypto.spec;version=0.0.0.1_006_JavaSE, javax.crypto;version=0.0.0.1_006_JavaSE, javax.imageio.event;version=0.0.0.1_006_JavaSE, javax.imageio.metadata;version=0.0.0.1_006_JavaSE, javax.imageio.plugins.bmp;version=0.0.0.1_006_JavaSE, javax.imageio.plugins.jpeg;version=0.0.0.1_006_JavaSE, javax.imageio.spi;version=0.0.0.1_006_JavaSE, javax.imageio.stream;version=0.0.0.1_006_JavaSE, javax.imageio;version=0.0.0.1_006_JavaSE, javax.jws.soap;version=0.0.0.1_006_JavaSE, javax.jws;version=0.0.0.1_006_JavaSE, javax.lang.model.element;version=0.0.0.1_006_JavaSE, javax.lang.model.type;version=0.0.0.1_006_JavaSE, javax.lang.model.util;version=0.0.0.1_006_JavaSE, javax.lang.model;version=0.0.0.1_006_JavaSE, javax.management.loading;version=0.0.0.1_006_JavaSE, javax.management.modelmbean;version=0.0.0.1_006_JavaSE, javax.management.monitor;version=0.0.0.1_006_JavaSE, javax.management.openmbean;version=0.0.0.1_006_JavaSE, javax.management.relation;version=0.0.0.1_006_JavaSE, javax.management.remote.rmi;version=0.0.0.1_006_JavaSE, javax.management.remote;version=0.0.0.1_006_JavaSE, javax.management.timer;version=0.0.0.1_006_JavaSE, javax.management;version=0.0.0.1_006_JavaSE, javax.naming.directory;version=0.0.0.1_006_JavaSE, javax.naming.event;version=0.0.0.1_006_JavaSE, javax.naming.ldap;version=0.0.0.1_006_JavaSE, javax.naming.spi;version=0.0.0.1_006_JavaSE, javax.naming;version=0.0.0.1_006_JavaSE, javax.net.ssl;version=0.0.0.1_006_JavaSE, javax.net;version=0.0.0.1_006_JavaSE, javax.print.attribute.standard;version=0.0.0.1_006_JavaSE, javax.print.attribute;version=0.0.0.1_006_JavaSE, javax.print.event;version=0.0.0.1_006_JavaSE, javax.print;version=0.0.0.1_006_JavaSE, javax.rmi.CORBA;version=0.0.0.1_006_JavaSE, javax.rmi.ssl;version=0.0.0.1_006_JavaSE, javax.rmi;version=0.0.0.1_006_JavaSE, javax.script;version=0.0.0.1_006_JavaSE, javax.security.auth.callback;version=0.0.0.1_006_JavaSE, javax.security.auth.kerberos;version=0.0.0.1_006_JavaSE, javax.security.auth.login;version=0.0.0.1_006_JavaSE, javax.security.auth.spi;version=0.0.0.1_006_JavaSE, javax.security.auth.x500;version=0.0.0.1_006_JavaSE, javax.security.auth;version=0.0.0.1_006_JavaSE, javax.security.cert;version=0.0.0.1_006_JavaSE, javax.security.sasl;version=0.0.0.1_006_JavaSE, javax.sound.midi.spi;version=0.0.0.1_006_JavaSE, javax.sound.midi;version=0.0.0.1_006_JavaSE, javax.sound.sampled.spi;version=0.0.0.1_006_JavaSE, javax.sound.sampled;version=0.0.0.1_006_JavaSE, javax.sql.rowset.serial;version=0.0.0.1_006_JavaSE, javax.sql.rowset.spi;version=0.0.0.1_006_JavaSE, javax.sql.rowset;version=0.0.0.1_006_JavaSE, javax.sql;version=0.0.0.1_006_JavaSE, javax.swing.border;version=0.0.0.1_006_JavaSE, javax.swing.colorchooser;version=0.0.0.1_006_JavaSE, javax.swing.event;version=0.0.0.1_006_JavaSE, javax.swing.filechooser;version=0.0.0.1_006_JavaSE, javax.swing.plaf.basic;version=0.0.0.1_006_JavaSE, javax.swing.plaf.metal;version=0.0.0.1_006_JavaSE, javax.swing.plaf.multi;version=0.0.0.1_006_JavaSE, javax.swing.plaf.synth;version=0.0.0.1_006_JavaSE, javax.swing.plaf;version=0.0.0.1_006_JavaSE, javax.swing.table;version=0.0.0.1_006_JavaSE, javax.swing.text.html.parser;version=0.0.0.1_006_JavaSE, javax.swing.text.html;version=0.0.0.1_006_JavaSE, javax.swing.text.rtf;version=0.0.0.1_006_JavaSE, javax.swing.text;version=0.0.0.1_006_JavaSE, javax.swing.tree;version=0.0.0.1_006_JavaSE, javax.swing.undo;version=0.0.0.1_006_JavaSE, javax.swing;version=0.0.0.1_006_JavaSE, javax.tools;version=0.0.0.1_006_JavaSE, javax.transaction.xa;version=0.0.0.1_006_JavaSE, javax.transaction;version=0.0.0.1_006_JavaSE, javax.xml.bind.annotation.adapters;version=0.0.0.1_006_JavaSE, javax.xml.bind.annotation;version=0.0.0.1_006_JavaSE, javax.xml.bind.attachment;version=0.0.0.1_006_JavaSE, javax.xml.bind.helpers;version=0.0.0.1_006_JavaSE, javax.xml.bind.util;version=0.0.0.1_006_JavaSE, javax.xml.bind;version=0.0.0.1_006_JavaSE, javax.xml.crypto.dom;version=0.0.0.1_006_JavaSE, javax.xml.crypto.dsig.dom;version=0.0.0.1_006_JavaSE, javax.xml.crypto.dsig.keyinfo;version=0.0.0.1_006_JavaSE, javax.xml.crypto.dsig.spec;version=0.0.0.1_006_JavaSE, javax.xml.crypto.dsig;version=0.0.0.1_006_JavaSE, javax.xml.crypto;version=0.0.0.1_006_JavaSE, javax.xml.datatype;version=0.0.0.1_006_JavaSE, javax.xml.namespace;version=0.0.0.1_006_JavaSE, javax.xml.parsers;version=0.0.0.1_006_JavaSE, javax.xml.soap;version=0.0.0.1_006_JavaSE, javax.xml.stream.events;version=0.0.0.1_006_JavaSE, javax.xml.stream.util;version=0.0.0.1_006_JavaSE, javax.xml.stream;version=0.0.0.1_006_JavaSE, javax.xml.transform.dom;version=0.0.0.1_006_JavaSE, javax.xml.transform.sax;version=0.0.0.1_006_JavaSE, javax.xml.transform.stax;version=0.0.0.1_006_JavaSE, javax.xml.transform.stream;version=0.0.0.1_006_JavaSE, javax.xml.transform;version=0.0.0.1_006_JavaSE, javax.xml.validation;version=0.0.0.1_006_JavaSE, javax.xml.ws.handler.soap;version=0.0.0.1_006_JavaSE, javax.xml.ws.handler;version=0.0.0.1_006_JavaSE, javax.xml.ws.http;version=0.0.0.1_006_JavaSE, javax.xml.ws.soap;version=0.0.0.1_006_JavaSE, javax.xml.ws.spi;version=0.0.0.1_006_JavaSE, javax.xml.ws.wsaddressing;version=0.0.0.1_006_JavaSE, javax.xml.ws;version=0.0.0.1_006_JavaSE, javax.xml.xpath;version=0.0.0.1_006_JavaSE, javax.xml;version=0.0.0.1_006_JavaSE, org.ietf.jgss;version=0.0.0.1_006_JavaSE, org.omg.CORBA.DynAnyPackage;version=0.0.0.1_006_JavaSE, org.omg.CORBA.ORBPackage;version=0.0.0.1_006_JavaSE, org.omg.CORBA.TypeCodePackage;version=0.0.0.1_006_JavaSE, org.omg.CORBA.portable;version=0.0.0.1_006_JavaSE, org.omg.CORBA;version=0.0.0.1_006_JavaSE, org.omg.CORBA_2_3.portable;version=0.0.0.1_006_JavaSE, org.omg.CORBA_2_3;version=0.0.0.1_006_JavaSE, org.omg.CosNaming.NamingContextExtPackage;version=0.0.0.1_006_JavaSE, org.omg.CosNaming.NamingContextPackage;version=0.0.0.1_006_JavaSE, org.omg.CosNaming;version=0.0.0.1_006_JavaSE, org.omg.Dynamic;version=0.0.0.1_006_JavaSE, org.omg.DynamicAny.DynAnyFactoryPackage;version=0.0.0.1_006_JavaSE, org.omg.DynamicAny.DynAnyPackage;version=0.0.0.1_006_JavaSE, org.omg.DynamicAny;version=0.0.0.1_006_JavaSE, org.omg.IOP.CodecFactoryPackage;version=0.0.0.1_006_JavaSE, org.omg.IOP.CodecPackage;version=0.0.0.1_006_JavaSE, org.omg.IOP;version=0.0.0.1_006_JavaSE, org.omg.Messaging;version=0.0.0.1_006_JavaSE, org.omg.PortableInterceptor.ORBInitInfoPackage;version=0.0.0.1_006_JavaSE, org.omg.PortableInterceptor;version=0.0.0.1_006_JavaSE, org.omg.PortableServer.CurrentPackage;version=0.0.0.1_006_JavaSE, org.omg.PortableServer.POAManagerPackage;version=0.0.0.1_006_JavaSE, org.omg.PortableServer.POAPackage;version=0.0.0.1_006_JavaSE, org.omg.PortableServer.ServantLocatorPackage;version=0.0.0.1_006_JavaSE, org.omg.PortableServer.portable;version=0.0.0.1_006_JavaSE, org.omg.PortableServer;version=0.0.0.1_006_JavaSE, org.omg.SendingContext;version=0.0.0.1_006_JavaSE, org.omg.stub.java.rmi;version=0.0.0.1_006_JavaSE, org.w3c.dom.bootstrap;version=0.0.0.1_006_JavaSE, org.w3c.dom.events;version=0.0.0.1_006_JavaSE, org.w3c.dom.ls;version=0.0.0.1_006_JavaSE, org.w3c.dom;version=0.0.0.1_006_JavaSE, org.xml.sax.ext;version=0.0.0.1_006_JavaSE, org.xml.sax.helpers;version=0.0.0.1_006_JavaSE, org.xml.sax;version=0.0.0.1_006_JavaSE
于 2012-08-14T09:19:53.120 回答
2

使用 JNDI 数据源而不是直接的 jdbc 连接可能会更好。Aries 博客示例有一个 blog.datasource 包,它使用蓝图注册数据源。所需捆绑包的列表比您当前拥有的要长,但您可以从 blog-assembly/target 目录或 pom.xml 中将它们全部复制。

或者,Aries 有一个 org.apache.aries.jpa.eclipselink.adapter,它与您链接到的文章做同样的事情。Aries 使用它来针对 EclipseLink 进行测试,所以它肯定可以工作。您还可以查看 Aries 测试以了解它是如何使用的,并查看是否有可以复制的 EclipseLink 测试。

于 2012-08-09T04:49:44.513 回答
0

使用gemini blueprint dbAccess 插件( http://www.eclipse.org/gemini/dbaccess/ )时事情可能会更容易,我认为它也适用于Aries。对于 MySQL,请务必包含连接器插件(例如http://ebr.springsource.com/repository/app/bundle/version/detail?name=com.springsource.com.mysql.jdbc&version=5.1.6)。这应该足以让数据库启动并运行,前提是 blueprint.xml(使用上面的示例)配置正确,如上所述。

于 2013-03-25T13:17:27.837 回答