JPA2 on WebSphere 7 with Spring : java.lang.NoSuchMethodError on PersistenceUnitInfo
Hi,
I try to deploy a webapp on WebSphere7 with JPA2.0 and I have this error :
Code:
Caused by: java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
at org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo(LogHelper.java:39)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:516)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
I investigate and I understand that the source of the problem come from SmartPersistenceUnitInfo class (spring-orm-3.0.5.RELEASE.jar) which not implements getSharedCacheMode() method.
So DefaultPersistenceUnitManager class check if PersistenceUnitInfo interface has the getSharedCacheMode() method and so application use JPA2.0, else use JPA1.0 and initiliaze the jpa2ApiPresent attribut.
With the value of jpa2ApiPresent, DefaultPersistenceUnitManager define if Spring use a proxy to simulate getSharedCacheMode() call or not.
Code:
if (jpa2ApiPresent) {
puiToStore = (PersistenceUnitInfo) Proxy.newProxyInstance(SmartPersistenceUnitInfo.class.getClassLoader(),
new Class[] {SmartPersistenceUnitInfo.class}, new Jpa2PersistenceUnitInfoDecorator(pui));
}
The problem is that WebSphere have a PersistenceUnitInfo interface define and it is load before hibernate-jpa-2.0-api-1.0.0.Final.jar library (in webapp lib directory) and so jpa2ApiPresent is always false.
I try to define ClassLoader of WebSphere as PARENT-LAST with admin console, but I have always the same error.(I don't understand why it's not work!)
I try also to define an another persitance provider to WebSphere but I don't understand how it really works.
Thanks for your help.