I have a spring web application that is accessed one of 2 ways - Servlet (SOAP) or RMI. There are no session beans but the spring beans have repository classes injected into them that contain an entity manager (@PersistenceContext(unitName="xxx" private EntityManager em). The spring application is configured to use the container managed entity manager and the persistence.xml is configured to use Hibernate. The persistence-unit-ref descriptors are in the web.xml.
If after starting the glassfish server, I access my spring bean through RMI (Spring remoting), I get the error "Unable to retrieve EntityManagerFactory for unitName xxx". If, I then access the same spring bean through a servlet (SOAP), everything works fine and the Hibernate entity manager implementation is returned properly. After I have accessed the entity manager through the servlet and only after that, the RMI route works correctly.
I don't know what is going on, if there is a bug in glassifsh or if there is something I need to do to configure this properly.
Help is appreciated. Thanks! Below is the stack trace:
java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName xxx
at com.sun.enterprise.util.EntityManagerFactoryWrapper.getDelegate(EntityManagerFactoryWrapper.java:93)
at com.sun.enterprise.util.EntityManagerFactoryWrapper.createEntityManager(EntityManagerFactoryWrapper.java:104)
at org.springframework.orm.jpa.EntityManagerFactoryUtils.doGetTransactionalEntityManager(EntityManagerFactoryUtils.java:193)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:171)
at $Proxy204.createQuery(Unknown Source)
[Message sent by forum member 'melodyk' (melodyk)]
http://forums.java.net/jive/thread.jspa?messageID=331345