-
JPA in JEE with Spring
I'm using Spring 3.0.2 with GlassFish 3 (JDK6 / JEE 6)
I'm using JPA (EclipseLink 2.0) for my persistence provider in addition to the Spring JpaTemplate. I've got my Dao's defined with @Resource and they are auto discovered by Spring via the <context:component-scan> element. Everything seems to work very well together but I'm having a difficult time locating the EntityManager. I'm attempting to deploy the application as an EJB only app, which means I must bundle it within an EAR. But I can't seem to get Spring to locate the EntityManager or more precisely, the PersistenceUnit.
I've tried the default
Code:
<jndi:lookup id="entitymanager" jndi-name="myPersistenceUnit"/>
and I've tried
Code:
<bean id="entityManager" class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor>
<property name="persistenceUnits">
<map>
<entry key="myPersistenceUnit" value="persistence/myPersistenceUnit"/>
</map>
</property>
</bean>
But that did not work either. I want to use the EntityManager configured for the application and defined in JNDI rather than a Local instance, but I simply can't seem to get this to work.
Any help is greatly appreciated.
Thanks....