Spring 2.5 LocalContainerEntityManagerFactoryBean, no getSharedCacheMode()

#1

I'm trying to setup Spring + JPA + ObjectDb in my test environment and having trouble with the following:

<bean id="EnvDMSEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="envService"/>
    <property name="persistenceXmlLocation" value="com/company/persistence.xml"/>
</bean>

Here is the stack trace I get:

Caused by: java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
at com.objectdb.jpa.EMF.init(EMF.java:86)
at com.objectdb.jpa.Provider.newEMF(Provider.java:134)
at com.objectdb.jpa.Provider.createContainerEntityManagerFactory(Provider.java:118)
at com.objectdb.jpa.Provider.createContainerEntityManagerFactory(Provider.java:32)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 45 more

This is with Spring 2.5.6. I'm doing it this way instead of using LocalEntityManagerFactory due to the constraints of my test setup and difficulty in placing persistence.xml in one of the conventional places. It is much easier to specify the location as a property on the bean. Why do I get this exception?

#2

This old version of Spring (released in 2008) supports only JPA 1.0. To instantiate an EntityManagerFactory it passes to ObjectDB a PersistenceUnitInfo instance of JPA 1.0, which is missing the getSharedCacheMode, and when ObjectDB tries to access that method the exception is thrown.

The problem should be solved by switching to a newer version of Spring Framework that supports JPA 2.0.

ObjectDB Support
#3

That makes sense, thank you for the reply. However I'm not sure why using a Spring-wired LocalEntityManagerFactoryBean with a jar/META-INF/persistence.xml works fine. Its only when I use the LocalContainerEntityManagerFactoryBean that ObjectDb makes a method call to the non-existing method. Is there some property I can set so that the call to getSharedCacheMode is not invoked?

#4

Please try build 2.5.1_06 that should silently ignore this specific exception.

Other JPA version conflicts, however, are possible with that old Spring Framework version.

ObjectDB Support
#5

Build 2.5.1_06 now works great! Thank you very much for the quick build, I'm impressed by ObjectDB and the support.

Reply