Websphere 7 EntityManagerFactory创建问题 [英] Websphere 7 EntityManagerFactory creation problem

查看:105
本文介绍了Websphere 7 EntityManagerFactory创建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个Maven项目中,该项目使用seam 2.2.0,hibernate 3.5.0-CR-2作为JPA提供程序,DB2作为数据库服务器以及Websphere 7作为应用程序服务器.现在我面临着以下问题:

I'm working on a maven project which uses seam 2.2.0, hibernate 3.5.0-CR-2 as JPA provider, DB2 as database server and Websphere 7 as application server. Now I'm facing de following problem:

  • 在也被视为SEAM组件的EJB中,我想使用EJB容器(@PersistenceContext私有EntityManager em)中的EntityManager,而不是Seam的EntityManager(@In私有EntityManager em).但这是问题,我无法使用@PersistenceContext获得EntityManager.

在服务器日志中,它表示无法创建EntityManagerFactory并获取ClassCastException:

On server logs it sais that it cannot create an EntityManagerFactory and gets a ClassCastException:

java.lang.ClassCastException:org.hibernate.ejb.HibernatePersistence与javax.persistence.spi.PersistenceProvider不兼容

java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence incompatible with javax.persistence.spi.PersistenceProvider

在论坛上进行了大量调试和搜索之后,我认为问题是Websphere不使用Hibernate JPA提供程序.

After a lot of debugging and searching on forums I'm assuming that the problem is that Websphere doesn't use the Hibernate JPA provider.

有人遇到这个问题并且有解决方案吗?我已经为我的应用程序配置了WAS类加载器顺序,以便首先使用应用程序类加载器加载类,然后将所有必需的jar打包到应用程序耳朵中,如以下内容所示:

Has anyone faced this problem and has a solution? I configured already WAS class loader order for my application to load the classes with the application class loader first and I\ve packed all necessary jars in application ear as written in: WAS InfoCenter: Features for EJB 3.0 development . If necessary I'll post my persistence.xml, components.xml files and stack trace.

我发现这里也讨论了这个问题:

I've found this problem discussed also here:

  • Websphere EntityManagerFactory creation problem
  • Hibernate 3.3 fail to create entity manager factory in Websphere 7.0. Please help

任何提示都会有用.
预先感谢!
米哈埃拉(Mihaela)

Any hint will be useful.
Thanks in advance!
Mihaela

推荐答案

我怀疑您的EAR中已包含JPA API jar.使用最后一个父级"(也称为先使用应用程序类加载器加载类")时,您的应用程序正在加载javax.persistence.spi.PersistenceProvider类的第二个副本,该副本与WAS中包含的副本不兼容.您需要从EAR中删除这些类,或更改回父级优先"委派模式.

I suspect that you've included the JPA API jar in your EAR. When using "parent last" (also known as "load classes with application class loader first"), your application is loading a second copy of the javax.persistence.spi.PersistenceProvider class, which is incompatible with the copy included in WAS. You need to either remove those classes from your EAR or change back to "parent first" delegation mode.

这篇关于Websphere 7 EntityManagerFactory创建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆