257 words

Spring 2.5 LocalContainerEntityManagerFactoryBean, no getSharedCacheMode()

2013-08-07 00:05

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"/>

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?

purecharger's picture
Joined on 2013-08-07
User Post #1
2013-08-07 02:02

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #1,623
2013-08-07 14:18

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?

purecharger's picture
Joined on 2013-08-07
User Post #2
2013-08-07 14:21

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #1,624
2013-08-07 15:38

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

purecharger's picture
Joined on 2013-08-07
User Post #3

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB