【问题标题】:OSGI Bundle implementing JPA Using DataNucleus 4.0.0 ReleaseOSGI Bundle 使用 DataNucleus 4.0.0 版本实现 JPA
【发布时间】:2014-11-16 09:55:06
【问题描述】:

我正在尝试在 OSGI 环境 (Apache ServiceMix) 中使用 DataNucleus 实现 JPA。我正在遵循此处提到的指南-http://www.datanucleus.org/products/datanucleus/jpa/osgi.html(名称为“JPA 和 OSGi”下的部分) 根据此处的文档,我正在使用 DataNucleus JPA jar。所以我在 ServiceMix 上部署了这个 Jar 如下 -

osgi:install mvn:org.datanucleus/datanucleus-jpa/2.1.7

osgi:start bundleId

当这个 jar 导出持久性提供程序时,我已经正确地将我的 persistence.xml 文件中的提供程序更改为 org.datanucleus.jpa.PersistenceProviderImpl(由上述包导出)而不是通常的 org.datanucleus.api。 jpa.PersistenceProviderImpl 位于普通 J2EE JPA APP 中。

我还在我的 ServiceMix 上运行 DataNucleus Core Bundle,它是使用以下命令安装在我的 ServiceMix 上的 -

osgi:install mvn:org.datanucleus/datanucleus-core/4.0.0-release

osgi:start bundleId

请注意:我的 ServiceMix 上没有运行 datanucleus-api-jpa 包,根据文档,datanucleus-jpa 包将导出必要的类,因此不需要 datanucleus-api-jpa 包。

在运行时,我收到以下错误原因:java.lang.ClassNotFoundException: org.datanucleus.PersistenceConfiguration not found by org.datanucleus.jpa [261]

我注意到的是,DataNucleus Core 4.0.0-release 版本没有这个类,但是这个类存在于所有以前的版本(3.2.15)中。

我无法将 DataNucleus Core 版本 3.2.XX 部署到我的 ServiceMix 上,因为我有其他使用 DataNucleus Core 4.0.0-release 的捆绑包,并且由于单例创建问题,两者都不是一个选项。

请告诉我,如果您需要我发布我的代码,我会这样做。 请帮忙

干杯, 阿比吉特

【问题讨论】:

  • 当你说要使用 DataNucleus v4.x 的时候,为什么要使用“datanucleus-jpa”v2.1.x ??? v2.x 很久不支持了。
  • 加载 META-INF/services/javax.persistence.spi.PersistenceProvider 中的实现类的解决方法是将持久性提供程序导出为 OSGi 服务。这就是 DataNucleus JPA jar 所做的,它是最新版本 2.1.7。
  • 不,它不是“最新版本”。这是一个古老的版本。 “datanucleus-api-jpa”是目前支持的神器,阅读文档可见
  • 对不起,我不是指 datanucleus-api-jpa,而是指 datanucleus-jpa 工件
  • 正如我已经说过的......那是古老的。现在没有使用该工件,并且 datanucleus-api-jpa 是(即它取代了它)。所有这些都可以在文档中轻松找到

标签: jpa osgi classnotfoundexception datanucleus apache-servicemix


【解决方案1】:

总之,您使用了不正确/无效的 jar。 “datanucleus-jpa”在 DataNucleus v2 中被删除。所有最新版本都使用“datanucleus-api-jpa”(如果使用 JDO,则为“datanucleus-api-jdo”)。简单下载 4.0.x 的 DataNucleus zip 文件将非常清楚地显示这一点。

【讨论】:

    猜你喜欢
    • 2021-09-13
    • 2012-04-05
    • 2019-04-21
    • 2013-11-03
    • 2018-02-24
    • 2015-04-24
    • 2012-04-17
    • 2011-09-21
    • 1970-01-01
    相关资源
    最近更新 更多