Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Coonection timesout after 8 hours
Coonection timesout after 8 hours [message #1148951] Mon, 21 October 2013 21:17 Go to next message
Itay Yahimovitz is currently offline Itay YahimovitzFriend
Messages: 3
Registered: October 2013
Junior Member
Hey,

I'm having an issue where my connection times out after 8 hours of no activity.
The connection never get connected again which leads me to restart my web application.

I was trying to search for a solution and the only one I found was to use an external connection pool.
There is no build in solution for this in Eclipselink? I know Hibernate have the option to check the connection every time before performing any query.

Thanks!
Re: Coonection timesout after 8 hours [message #1150040 is a reply to message #1148951] Tue, 22 October 2013 13:43 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
EclipseLink has many configuration options and should by default retry queries and re-obtain connections, but it depends on the version and the configuration options you are using. Try the latest version, and turn logging on to see what is happening. Depending on the database platform you are using, you may need to set the ping SQL EclipseLink uses to check if the connection is valid. see http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/sessions/DatabaseLogin.html setPingSQL(string), which you can call in a session customizer: http://wiki.eclipse.org/Customizing_the_EclipseLink_Application_(ELUG)#Using_the_Session_Customizer_Class

You can also pass properties to your driver, so check what options it has. You can pass driver properties using http://www.eclipse.org/eclipselink/api/2.5/org/eclipse/persistence/config/PersistenceUnitProperties.html#JDBC_PROPERTY




Re: Coonection timesout after 8 hours [message #1150329 is a reply to message #1150040] Tue, 22 October 2013 17:54 Go to previous messageGo to next message
Itay Yahimovitz is currently offline Itay YahimovitzFriend
Messages: 3
Registered: October 2013
Junior Member
Thanks for your quick response!
I'm using version 2.5.1, the issue only occurs when I'm trying write, read queries are not failing at all.
I believe I found that the issue occurs when tomcat randomly restart itself and then I cannot write anymore.
I guess it can be that the default connection pool cannot acquire a connection and just hangs there forever.
Re: Coonection timesout after 8 hours [message #1153667 is a reply to message #1148951] Thu, 24 October 2013 19:26 Go to previous messageGo to next message
Itay Yahimovitz is currently offline Itay YahimovitzFriend
Messages: 3
Registered: October 2013
Junior Member
I found out that the PingSQL is set to the correct one so I guess it wouldn't help to customize the session.
Setting the autoConnect for mysql did not help too, I'm not sure what to do anymore.
I also have another issue now, sometimes I'm getting an exception:

Exception [EclipseLink-4005] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: DatabaseAccessor not connected.
at org.eclipse.persistence.exceptions.DatabaseException.databaseAccessorNotConnected(DatabaseException.java:123)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.incrementCallCount(DatasourceAccessor.java:325)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.beginTransaction(DatasourceAccessor.java:254)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicBeginTransaction(AbstractSession.java:676)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicBeginTransaction(AbstractSession.java:652)
at org.eclipse.persistence.internal.sessions.AbstractSession.beginTransaction(AbstractSession.java:847)
at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:448)
at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1067)
at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:266)
at org.eclipse.persistence.internal.sessions.AbstractSession.getNextSequenceNumberValue(AbstractSession.java:2672)

My persistence.xml looks like this:

<persistence version="2.0">
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="${jdbc.url}" />
<property name="javax.persistence.jdbc.user" value="${jdbc.username}" />
<property name="javax.persistence.jdbc.password" value="${jdbc.password}" />
<property name="eclipselink.target-database" value="MYSQL" />
<property name="eclipselink.logging.level" value="FINEST" />
<property name="eclipselink.orm.throw.exceptions" value="true" />
</properties
</persistence-unit>
</persistence>

[Updated on: Thu, 24 October 2013 19:27]

Report message to a moderator

Re: Coonection timesout after 8 hours [message #1154983 is a reply to message #1153667] Fri, 25 October 2013 15:58 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
That might happen if the underlying session is logged out while another thread is still using it. How are you obtaining EntityManager and EntityManagerFactory instances? Be sure not to close the factory instances until the EntityManager is done being used.

As for the write connection issue, more information is needed, such as when it is occurring and what the threads are doing that they hang. Try getting a thread dump to see what is happening.
Previous Topic:DB2 Stored Proc Call - Query is wrong
Next Topic:EclipseLink seems to ignore columnDefinition and nullable
Goto Forum:
  


Current Time: Thu Apr 25 15:08:47 GMT 2024

Powered by FUDForum. Page generated in 0.03277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top