1

I am currently using Eclipselink 2.5.0, with jdbc mysql connector 5.1.30 and mysql 5.6.?

I have several different classes using eclipselink, all which test fine in development. However, when running in production, I get intermittent communication errors. The errors are all similar, some happen during read queries, and some during persists. There does not seem to be a pattern but most have an error message similar to:

[EL Info]: 2015-01-15 02:44:26.131--ClientSession(362204393)--Communication failure detected when attempting to create transaction on database. Attempting to retry begin transaction. Error was: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1,430,108 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.

Error Code: 0.

OR when performing a read:

[EL Warning]: 2015-01-15 03:08:05.221--UnitOfWork(645415294)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 337,026 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago. Error Code: 0

I am new to JPA and not sure of the best practices. I have tried several different code solutions, but without any luck. At this time, I am creating a new entity manager for each transaction. I also tried a system singleton, and class singleton solution, for em, but those both produced intermittent errors as well. What is the best practice for entity managers, a) system singleton, b) query class singleton, or c) new instance per query?

Additionally, I have also wrapped all transactions, including reads, in em.getTransaction().begin() and em.getTransaction().commit(). The last attempt I added the begin() and commit() for the read queries, even though no examples were found online. Just getting desperate to make this work. Is there a need to add begin and commit around a read query?

Thanks in advance for any advice you can provide.

Bill Snee
  • 119
  • 1
  • 11
  • Not a duplicate. I have connection on my development server. I have connection on my production server. As stated above, the connection problem is intermittent. The program starts with good connections and no complaints. Over time, It seems to generate more and more error reports. The connection is handled through the eclipselink persistence.xml. I've tried clearing the entity manager upon every instance call, but that did not resolve the problem. – Bill Snee Jan 16 '15 at 21:21
  • This one might be another candidate: http://stackoverflow.com/questions/9949516/processing-on-mysql-query-taking-too-long-and-throwing-communications-link-fail?rq=1 – Mark Rotteveel Jan 17 '15 at 08:01
  • 1
    The issue has been resolved. The problem is that in many of the entity manager usage examples, the em is not closed. Since I was not closing the em, eventually the connection pool ran out and threw an exception. Would still like to get some best practices type information w.r.t. using an em and the jpa but will forge ahead. – Bill Snee Jan 17 '15 at 17:16

0 Answers0