开发者

Websphere 7 EntityManagerFactory creation problem

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:

  • In my EJBs that are seen also as SEAM components I want to use the EntityManager from EJB container (@PersistenceContext private E开发者_如何学CntityManager em) not Seam's EntityManager (@In private EntityManager em). But this is the problem, I cannot obtain an EntityManager using @PersistenceContext.

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

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

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.

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

Any hint will be useful.

Thanks in advance!

Mihaela


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜