karrirasinmaki / app-engine-workarounds

Automatically exported from code.google.com/p/app-engine-workarounds
0 stars 0 forks source link

Spring JPA and LocalEntityManagerFactoryBean #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I use Spring JPA and LocalEntityManagerFactoryBean to create the GAE
entity manager factory I get:

java.lang.IllegalStateException: Application code attempted to create a
EntityManagerFactory named transactions-optional, but one with this name
already exists! Instances of EntityManagerFactory are extremely slow to
create and it is usually not necessary to create one with a given name more
than once. Instead, create a singleton and share it throughout your code.
If you really do need to create a duplicate EntityManagerFactory (such as
for a unittest suite), set the
appengine.orm.disable.duplicate.emf.exception system property to avoid this
error.

Is there any workaround for this? I'm using the configuration on the
project home page:

    <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"
lazy-init="true">
        <property name="persistenceUnitName" value="transactions-optional"/>
    </bean>

Original issue reported on code.google.com by tlees...@gmail.com on 10 Feb 2010 at 9:05

GoogleCodeExporter commented 9 years ago
Just add to your appengine-web.xml

<system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
    <property name="appengine.orm.disable.duplicate.emf.exception" value="true" />
</system-properties>

Original comment by lucian...@gmail.com on 29 Nov 2010 at 12:53

GoogleCodeExporter commented 9 years ago
I resolved this a long time ago and it was related to how I had setup a couple 
of <context:component-scan /> elements. This can probably be closed as invalid 
since it was my code causing the problem.

Original comment by tlees...@gmail.com on 29 Nov 2010 at 5:30