openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <>
Subject Re: MySQL Timeout issue
Date Fri, 04 Jan 2013 19:13:58 GMT
Hi David,
This sounds strange or, at least, unique.  Normal, default processing by
OpenJPA is to only get a database connection when it's needed and then
release it as soon as possible (flush or commit).  There are other options
[1] available to extend the life of the connection to either the
transaction or until the EM closes, but you would have to set that
explicitly.  Are you using either of these?

Or, is there some other processing in your application that is accidentally
holding onto the connection?  Via OpenJPA APIs, there is a means of
obtaining the connection object, but again that's not normal processing.
Normally, apps would just like OpenJPA handle the connection management
processing.  One of the benefits of JPA...

Are you using OpenJPA in a JSE environment, or as part of an application
server?  Just wondering if there's something else holding onto connections
outside of OpenJPA's control.  Like some connection management or
connection pooling utility?  By default, OpenJPA will use DBCP for
connection pooling in the JSE environment [2].  There have been some issues
relating to DBCP and stale connections in the pool, but I thought those
were cleared up in the past...  You could try disabling the DBCP support
and see if that resolve it as a quick test.

Bottom line is that I think OpenJPA is just the messenger in this case.
Some connection was given to OpenJPA that was stale and we just reported
the error.  Hopefully, this note gives you a few areas to check on.  Let us
know what you find out.



On Fri, Jan 4, 2013 at 6:39 AM, David Beer <>wrote:

> Hi All
> I periodically get an issue where the connection to my MySQL Database
> timesout. I have set the value <property name="openjpa.**ConnectionFactoryProperties"
> value="autoReconnect=true"/> in the persistence.xml file and this works
> most of the time but if there is a long time between the connection like a
> few days it timesout. Is this a case of increasing the timeout value in
> MySQL or is this a setting in OpenJpa I need to change?
> My stack trace is as follows:
> 02-Jan-2013 01:44:27 com.copperarrow.utils.**autotrial.SNSRecieverServlet
> messageProcessed
> SEVERE: Problem executin query find by id
> <openjpa-2.2.0-r422266:1244990 fatal general error> org.apache.openjpa.**
> persistence.**PersistenceException: The last packet successfully received
> from the server was 187,404,662 milliseconds ago.  The last packet sent
> successfully to the server was 187,404,662 milliseconds ago. is longer than
> the server configured value of 'wait_timeout'. You should consider either
> expiring and/or testing connection validity before use in your application,
> increasing the server configured values for client timeouts, or using the
> Connector/J connection property 'autoReconnect=true' to avoid this problem.
>         at org.apache.openjpa.jdbc.sql.**DBDictionary.narrow(**
>         at org.apache.openjpa.jdbc.sql.**DBDictionary.**newStoreException(
> **
> My MySQL Settings are as follows for default timeout.
> mysql> SHOW GLOBAL VARIABLES LIKE "wait_timeout";
> +---------------+-------+
> | Variable_name | Value |
> +---------------+-------+
> | wait_timeout  | 28800 |
> +---------------+-------+
> 1 row in set (0.00 sec)
> Thanks
> David

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message