websphere 7 和(基于应用程序)open-jpa 2

发布于 2024-12-01 12:53:13 字数 1515 浏览 5 评论 0原文

我不想使用内置的 Websphere 7 jpa 插件,而是使用应用程序 WEB-INF/lib/open-jpa 2 和专有的持久性提供程序。我无法安装 Websphere 的 OSGI 和 JPA 2 功能包。

最初,我只是在尝试加载 persistence.xml (不支持 version="2")时遇到了 sax 解析错误。该错误是由 open-jpa 1.2.3 中的一个类引发的。当我运行 websphere/appserver/bin/wsjpaversion.bat 时,会显示 open-jpa 1.2.3 jar。默认情况下,它会覆盖应用程序中的 open-jpa 2 jar。我创建了一个包含 open-jpa 2 jar 的共享库,并选中了此配置选项:“对此共享库使用隔离的类加载器”。我将应用程序类加载器设置为最后加载父级,并为其分配新的共享库资源。 “版本 2”错误消失了,但还有另一个问题。当我尝试初始化 EntityManager 时,出现错误:

Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:121)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:91)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    ... 2 more
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:110)
    ... 11 more

更多细节:在 persistence.xml 中,provider 元素设置为专有的 PersistenceProviderImpl,而不是默认的 Websphere 持久性提供程序。那么这个 websphere 默认值是从哪里来的以及如何阻止它呢? (另一个重要说明:当我完全删除 persistence.xml 时,我收到相同的错误

谢谢

I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere.

Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open-jpa 2 jar in the app. I created a shared library containing the open-jpa 2 jar with this config option checked: 'Use an isolated class loader for this shared library'. I set my application classloader to load parent last and assigned it the new shared library resource. The 'version 2' error is gone, but there is another problem. When I try to initialize an EntityManager I get an error:

Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:121)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:91)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    ... 2 more
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:110)
    ... 11 more

One more detail: inside the persistence.xml, the provider element is set to the proprietary PersistenceProviderImpl not the default Websphere persistence provider. So where is this websphere default coming from and how do I prevent it? (another important note: when I remove persistence.xml completely, I get the same error)

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睫毛上残留的泪 2024-12-08 12:53:13

如果不安装功能包,您将面临一场失败的战斗。虽然可以插入您自己的 JPA 实现,但使用 JPA API 则无法做到这一点 — 因此 WAS 7 将您与 JPA 1.0 版本联系在一起(请参阅,例如,此处这是如何完成的 - 不过,任何类加载器策略都不会改变这一点它乍一看似乎很诱人)。

Without installing the feature pack, you're fighting a losing battle. While it is possible to plug in your own JPA implementation, it is not possible to do that with JPA API — so WAS 7 ties you to the 1.0 version of JPA (see, for example, here how this is done — no class loader policy juggling will change that, though it seems tempting at first).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文