【发布时间】:2011-02-16 00:47:40
【问题描述】:
我正在开发一个使用 seam 2.2.0、hibernate 3.5.0-CR-2 作为 JPA 提供程序、DB2 作为数据库服务器和 Websphere 7 作为应用程序服务器的 maven 项目。现在我面临以下问题:
- 在我也被视为 SEAM 组件的 EJB 中,我想使用来自 EJB 容器的 EntityManager(@PersistenceContext 私有 EntityManager em),而不是 Seam 的 EntityManager(@In 私有 EntityManager em)。但这就是问题所在,我无法使用 @PersistenceContext 获取 EntityManager。
在服务器日志上,它说它无法创建 EntityManagerFactory 并获得 ClassCastException:
java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence 与 javax.persistence.spi.PersistenceProvider 不兼容
在论坛上进行大量调试和搜索后,我假设问题在于 Websphere 不使用 Hibernate JPA 提供程序。
有没有人遇到过这个问题并有解决方案?我已经为我的应用程序配置了 WAS 类加载器顺序,以首先使用应用程序类加载器加载类,并且我已经在应用程序 ear 中打包了所有必要的 jar,如下所示:WAS InfoCenter: Features for EJB 3.0 development 。如有必要,我将发布我的 persistence.xml、components.xml 文件和堆栈跟踪。
我发现这里也讨论过这个问题:
- Websphere EntityManagerFactory creation problem
- Hibernate 3.3 fail to create entity manager factory in Websphere 7.0. Please help
任何提示都会很有用。
提前致谢!
米哈埃拉
【问题讨论】:
标签: jpa ejb-3.0 websphere entitymanager