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.