views:

471

answers:

1

Hello,

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 EntityManager 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:

Any hint will be useful.
Thanks in advance!
Mihaela

+1  A: 

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.

bkail
Thank you for the hint. Indeed I've included also the JPA API jar in my EAR. This didn't solve my problem yet (anyway I got another exception), but I must first review the jars needed for Hibernate and the correct scope.
mihaela
Well, I can't help solve your problem unless you describe it :-). Perhaps upvote and update your problem description, or accept and start a new question?
bkail
I'm still trying some scenarious and only after that I can come back with a more clear description
mihaela