#1155 new
Jan Bohus

Async job - No operations allowed after connection closed.Connection was implicitly closed by the driver.

Reported by Jan Bohus | October 9th, 2011 @ 01:15 PM

Hello,
I have a job called ReplyMqConsumer, this job is most of the time waiting for messages from RabbitMQ queue (RabbitMQConsumer is from RabbitMQ plugin). When a massage is recieved, it should find a record in the database. And here comes the problem - when is the consume() called few minutes after application start, everything is fine. But if the job is running for longer time (one hour or so) without any activity (means, wainting for message), then the Log.findById() raises an exception - the db connection is closed. I belive, it's becasue the job is in the wait state for a long time thus the db connection timed out, but shouldn't the Play db mannagement create new DB connection then?

**Job code: @OnApplicationStart(async = true) public class ReplyMqConsumer extends RabbitMQConsumer {

@Override protected void consume(ReplyMqPrimitive message) {

Log log = Log.findById(message.getApcl());
if(log!=null){
    processReply(message, log);
}

}

}

**Exception raised: 01:55:11,203 ERROR ~ No operations allowed after connection closed.Connection was implicitly closed by the driver.
01:55:11,207 ERROR ~ Error processing message (ext.ReplyMqPrimitive@622d795d) with consumer (jobs.ReplyMqConsumer). Exception:
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not load an entity: [models.Log#12]

at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:635)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:589)
at play.db.jpa.JPQL.findById(JPQL.java:34)
at models.Log.findById(APCommandLog.java)
at jobs.ReplyMqConsumer.consume(ReplyMqConsumer.java:35)
at jobs.ReplyMqConsumer.consume(ReplyMqConsumer.java:1)
at play.modules.rabbitmq.consumer.RabbitMQMessageConsumerJob.doJob(RabbitMQMessageConsumerJob.java:84)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.modules.rabbitmq.consumer.RabbitMQConsumer.goGetHerSon(RabbitMQConsumer.java:153)
at play.modules.rabbitmq.consumer.RabbitMQConsumer.doJob(RabbitMQConsumer.java:98)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)

Caused by: org.hibernate.exception.JDBCConnectionException: could not load an entity: [models.Log#12]

at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2041)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3293)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:614)
... 18 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1213)
at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1200)
at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4203)
at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4169)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
... 30 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 10,875,022 milliseconds ago. The last packet sent successfully to the server was 10,875,022 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3348)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1967)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2273)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
... 32 more

Caused by: java.net.SocketException: Broken pipe

at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3329)
... 41 more

**Framework version: Play 1.2.3

**Platform you're using: MariaDB 5.2 with INNODB, OpenJDK 1.6.0_23, Linux 2.6 AMD64

Comments and changes to this ticket

  • Jan Bohus

    Jan Bohus October 9th, 2011 @ 03:05 PM

    My connection url:
    jdbc:mysql://192.168.68.1:3306/mydb?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci&autoReconnect=true

  • Jerry

    Jerry February 11th, 2019 @ 10:44 AM

    I have a blog post about spotify that I would like to share with you guys if you have an interest in music and especially looking for free music on your Android device.

  • Katy Perry

    Katy Perry June 10th, 2019 @ 05:02 PM

    Spotify is the best online music streaming application. it is the best Music app out there. in Spotify Premium Apk you will find tons of music collection, audiobooks, podcast and so on. You can share your music playlist with your friends without spending a penny. Today we are going to share the guide on How to Download Spotify Premium Apk and Install on Android Devices.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2>Play framework</h2>

Play makes it easier to build Web applications with Java. It is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Learn more on the <a href="http://www.playframework.org">http://www.playframework.org</a> website.<br><br>

<h2>Source code is hosted on github</h2>Check out our repository at <a href="http://github.com/playframework/play">http://github.com/playframework/play</a><br><br>

<h2>Contributing, creating a patch</h2> Please read the <a href="http://play.lighthouseapp.com/projects/57987/contributor-guide">contributor guide</a><br><br>

<h2>Reporting Security Vulnerabilities</h2> Since all bug reports are public, please report any security vulnerability directly to <em>guillaume dot bort at gmail dot com</em>.<br><br>

<h2>Creating a bug report</h2> Bug reports are incredibly helpful, so take time to report bugs and request features in our ticket tracker. We’re always grateful for patches to Play’s code. Indeed, bug reports with attached patches will get fixed far quickly than those without any.<br><br>

Please include as much relevant information as possible including the exact framework version you're using and a code snippet that reproduces the problem.<br><br>

Don't have too much expectations. Unless the bug is really a serious "everything is broken" thing, you're creating a ticket to start a discussion. Having a patch (or a branch on Github we can pull from) is better, but then again we'll only pull high quality branches that make sense to be in the core of Play.

People watching this ticket

Pages