Viv*_*wal 4 websphere jpa websphere-8
我收到以下错误
[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.
Run Code Online (Sandbox Code Playgroud)
我仔细阅读了上述链接和其他论坛中提供的答案.常见的建议是删除JPA 2.0 jar(我不能这样做)并使类加载器成为父最后一个.
除此之外还有其他解决方案吗?就像在我的persistence.xml中定义一些属性一样.
我的websphere版本是8.5.5.2.
In my persistence.xml
<provider>org.hibernate.ejb.HibernatePersistence</provider>
Run Code Online (Sandbox Code Playgroud)
===================更新=======================
小智 9
如您引用的其他帖子中所述,基本问题是您的系统中有多个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提供程序获得应用程序管理的持久性,但您将受限于可用的功能.