Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] Eclipselink reconnects to db on each call

The symptoms suggest that you are releasing the EntityManagerFactory(EMF) for garbage collection or actually closing the EMF.  If there are no active EMFs in your application then EclipseLink will close out the backing sessions effectively shutting down the Persistence Service.  This functionality allows for redeployment of your application.
Try holding a static reference to the EMF you create or make sure that the EMF is held for the life of your application.
--Gordon

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx]On Behalf Of Vespa,
Anthony J
Sent: Friday, December 07, 2007 9:37 AM
To: EclipseLink User Discussions
Subject: [eclipselink-users] Eclipselink reconnects to db on each call


Hello,

I'm having a bit of an issue and wondering if anyone has seen this
before.

I have a persistence.xml with 3 different persistence units as I have
segmented my logic into three different Oracle schema.  Within the Java
code, there are times where I access different persistence units
(depending on the data I need) - now that I am using cache coordination,
performance seems much worse, and part of it seems to be that within 30
seconds or so of a call being executed, the connections to the various
Pus are closed and the connection is logged out.

If I comment out the lines for cache coordination / RMI, things work as
they should - eg it doesn't time out and performance is reasonable.

I did add this property to my persistence.xml just to see if it had any
effect

<property name="eclipselink.jdbc.timeout" value="300000"/>

But it didn't seem to.

To actually get a connection I am calling a getMamanger() function in a
class that looks like this:from some of my business logic:

public class DBManager {

    protected RMICacheCoordinationConfig RMIcc;
    protected EntityManagerFactory emf;
    protected EntityManager em;

     public EntityManager getManager(String s) {
        try {
            if (emf == null) {
                emf = Persistence.createEntityManagerFactory(s);
			RMIcc = new  RMICacheCoordinationConfig();
                  RMIcc.customize(JpaHelper.getServerSession(emf));
                
                em = emf.createEntityManager();
            }
        }
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return em;
    }


}

I have a series of helper wrapper functions that call the different
EntityManager functions (load, remove, etc)

My RMI Caching function is what I got from the eclipselink list last
week - I'm new to RMI so I might have forgotten something:


public class RMICacheCoordinationConfig {


    public void customize(Session session) throws Exception {
            AbstractSession sessionImpl = (AbstractSession) session;

            RemoteCommandManager cm = new
RemoteCommandManager(sessionImpl);
            cm.setShouldPropagateAsynchronously(true);
            cm.getDiscoveryManager().setAnnouncementDelay(10);
            cm.getTransportManager().setNamingServiceType(
                    TransportManager.REGISTRY_NAMING_SERVICE);
            cm.setUrl("rmi://$HOST:1099");
            cm.setServerPlatform(sessionImpl.getServerPlatform());
            sessionImpl.setCommandManager(cm);
            sessionImpl.setShouldPropagateChanges(true);
            cm.initialize();
            try {
                Thread.sleep(5000);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    

}


Thanks for any help!

-Tony
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top