users@glassfish.java.net

Re: RE: Re: Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)

From: <glassfish_at_javadesktop.org>
Date: Fri, 16 Mar 2007 10:56:01 PST

It keeps getting more interesting. I tried our code on v2b39 to see if it behaved differently, and discovered that createEntityManagerFactory() throws a hissy fit if it's called multiple times witih the same PU name. Or, at least, that's what I'm guessing this exception means...

Exception [TOPLINK-28009] (Oracle TopLink Essentials - 2.0 (Build b39-rc (03/13/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: Attempted to redeploy a session named file:/Users/pohl/RCCL/build/web/WEB-INF/classes/-RCCLPU without closing it.
        at oracle.toplink.essentials.exceptions.EntityManagerSetupException.attemptedRedeployWithoutClose(EntityManagerSetupException.java:76)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.addSessionToGlobalSessionManager(EntityManagerSetupImpl.java:262)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.initServerSession(EntityManagerSetupImpl.java:879)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:188)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:78)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:111)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:105)
        at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:76)
        at com.sun.enterprise.util.EntityManagerFactoryWrapper.createEntityManager(EntityManagerFactoryWrapper.java:91)
        at net.nanonation.rccl.beans.RestaurantsController.getEntityManager(RestaurantsController.java:52)


...so it looks like I need a process-wide singleton of the emf, which should be easy to accomplish. That will be my next experiment.
[Message sent by forum member 'pohl' (pohl)]

http://forums.java.net/jive/thread.jspa?messageID=208484