gpt4 book ai didi

jpa - Websphere JPA Persistence 与默认的 PersistenceProvider 不兼容

转载 作者:行者123 更新时间:2023-12-04 22:58:51 24 4
gpt4 key购买 nike

我收到以下错误

  [9/29/15 21:06:33:816 IST] 0000003f JPAPUnitInfo  E   CWWJP0015E: An error  occurred in the 
org.hibernate.ejb.HibernatePersistence persistence provider when it attempted to create the
container entity manager factory for the rga-hibernate-jpa persistence unit.
The following error occurred:
java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence
incompatible with javax.persistence.spi.PersistenceProvider.

这个问题很多人都遇到过。
1. this ,2. this ,3. and this

我浏览了上述链接和其他一些论坛中提供的答案。常见的建议是删除 JPA 2.0 jar(我不能这样做)并使类加载器作为父级最后。

除了这个还有什么解决办法吗?就像在我的persistence.xml 中定义一些属性一样。

我的 websphere 版本是 8.5.5.2。
In my persistence.xml    
<provider>org.hibernate.ejb.HibernatePersistence</provider>

====================更新========================

我的依赖是:
My dependency

最佳答案

如您引用的其他帖子所述,基本问题是您的系统中有多个 javax.persistence API 副本。很可能,您的应用程序中有一个(与 Hibernate impl 一起),一个由 WebSphere Application Server 提供。由于修改 WebSphere 几乎是不可能的,我建议探索删除 Hibernate JPA API jar 文件。

现在您需要注意这个问题的另一个方面......您没有提到您尝试使用哪个版本的 Hibernate 或哪个版本的 JPA。但是,WebSphere v8.5.5.2 仅限于 JPA 2.0。如果您尝试使用符合 JPA 2.1 的 Hibernate(或 EclipseLink 甚至 OpenJPA)版本,它将无法正常工作。您将立即遇到类加载问题。并且,没有解决方法。至少不是容器管理的持久性。您也许可以通过 JPA 2.1 提供程序获得一些与应用程序管理的持久性一起工作的东西,但您将受到可用功能的限制。

关于jpa - Websphere JPA Persistence 与默认的 PersistenceProvider 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32869479/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com