-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Connection timeout error
PostPosted: Mon Nov 19, 2007 7:43 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
I'm running tomcat and mysql. If I make a new http request to a webapp that's been sitting for a while (roughtly 40 minutes), the following error comes up. If I refresh the same request, the app works as expected. What might be causing this problem?

Thanks a lot,
Dave

Tomcat version:
5.5.25

Hibernate version:
3.2.5

Name and version of the database you are using:
Mysql 5.0.45


Full stack trace of any exception that occurs:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.hibernate.TransactionException: JDBC begin failed:
vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:84)

root cause

vitalvinyl.util.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed:
vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:179)
vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)

root cause

org.hibernate.TransactionException: JDBC begin failed:
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:68)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)

root cause

com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 17 ms ago.
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2874)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2764)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3286)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1852)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4654)
org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)

root cause

java.net.SocketException: Connection reset
java.net.SocketInputStream.read(SocketInputStream.java:168)
com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2330)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2775)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2764)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3286)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1852)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4654)
org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
Apache Tomcat/5.5.25


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 2:00 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
Here's the output from my tomcat's debug log.


11:21:17,374 DEBUG vitalvinyl.pos.action.Login: doSearch - start
11:21:17,394 DEBUG vitalvinyl.pos.action.Login: doSearch - start
11:21:17,480 DEBUG vitalvinyl.pos.action.BaseAction: isAuthenticated - start
11:21:17,487 DEBUG vitalvinyl.pos.action.BaseAction: isAuthenticated - start
11:21:25,221 DEBUG vitalvinyl.util.persistence.hibernate.SessionManagerFilter: doFilter - start
11:21:25,221 ERROR org.hibernate.transaction.JDBCTransaction: JDBC begin failed
com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3135)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1833)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4654)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
at vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:544)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3120)
... 26 more
11:21:25,222 FATAL vitalvinyl.util.persistence.hibernate.SessionManagerFilter: org.hibernate.TransactionException: JDBC begin failed:
vitalvinyl.util.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin failed:
at vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:179)
at vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:544)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.TransactionException: JDBC begin failed:
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:68)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
... 17 more
Caused by: com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3135)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1833)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4654)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
... 19 more
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3120)
... 26 more
11:21:25,222 DEBUG vitalvinyl.util.persistence.hibernate.SessionManagerFilter: doFilter - end
11:21:25,223 ERROR staging.vitalculture.com].[/].[webwork]: Servlet.service() for servlet webwork threw exception
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3120)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1833)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)
at com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4654)
at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
at org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at vitalvinyl.util.persistence.hibernate.HibernateHelper.beginTransaction(HibernateHelper.java:175)
at vitalvinyl.util.persistence.hibernate.SessionManagerFilter.doFilter(SessionManagerFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:544)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:773)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:703)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:895)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 7:34 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
I can replicate this problem in a quick fashion by setting MySQL's wait_timeout to a very low value, such as 35 seconds.

I've since attempted to use c3p0 to handle connections. But, I'm not having any luck with that either.

I've got these lines in my hibernate.properties file:

Code:
hibernate.c3p0.acquire_increment=3
hibernate.c3p0.idle_test_period=15
hibernate.c3p0.timeout=120
hibernate.c3p0.max_size=15
hibernate.c3p0.max_statements=0
hibernate.c3p0.min_size=3


And, these lines in my c3p0.properties file:

Code:
c3p0.preferredTestQuery=SELECT 1
c3p0.initialPoolSize=3
c3p0.maxConnectionAge=15
c3p0.idleConnectionTestPeriod=15
c3p0.testConnectionsOnCheckin=true
c3p0.testConnectionOnCheckout=true
c3p0.acquireRetryAttempts=30


When I run my webapp, I do see the values from hibernate.properties being used. However, I never see any mention of the c3p0.properties values. Both hibernate.properties and c3p0.properties are in my WEB-INF/classes/ path. Is there some newer convention for loading the additional c3p0 variables?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 4:40 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
After three weeks of going insane over this issue, I was finally able to rectify this problem by switching from a hibernate.properties to a hibernate.cfg.xml configuration for hibernate.

Thanks for not helping.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 3:24 pm 
Newbie

Joined: Fri Dec 07, 2007 3:21 pm
Posts: 1
I also having been going insane over this but only for a few days so far. I already use the hibernate.cfg.xml so that isn't resolving it for me. Any chance you changed something else that might have affected it?

thanks,

Ron


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 11:19 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
Well, all I know is that once I got the hibernate.cfg.xml file to load, there were definitely a lot more log entries for c3p0. Also, pay close attention to which c3p0 settings MUST be specified in the hibernate.cfg.xml It's my understanding that any other settings must be in the c3p0.properties.

Here's my hibernate.cfg.xml fie for your reference.

Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <property name="show_sql">true</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/someDatabase?autoReconnect=true</property
        <property name="hibernate.connection.username">someUsername</property>
        <property name="hibernate.connection.password">somePassword</property>
        <property name="hibernate.connection.pool_size">0</property>
        <property name="format_sql">false</property>
        <property name="hibernate.jdbc.use_scrollable_resultset">true</property>

        <!-- configuration pool via c3p0-->
        <property name="hibernate.c3p0.acquire_increment">3</property>
        <property name="hibernate.c3p0.idle_test_period">100</property> <!-- seconds -->
        <property name="hibernate.c3p0.max_size">100</property>
        <property name="hibernate.c3p0.max_statements">0</property>
        <property name="hibernate.c3p0.min_size">10</property>
        <property name="hibernate.c3p0.timeout">100</property> <!-- seconds -->
    </session-factory>
</hibernate-configuration>


And here's my c3p0.properties

Code:
c3p0.preferredTestQuery=SELECT 1
c3p0.initialPoolSize=3
c3p0.maxConnectionAge=15
c3p0.idleConnectionTestPeriod=15
c3p0.acquireRetryAttempts=30


And finally, my my.cnf

Code:

[mysqld]
skip-innodb
max_connections = 600
max_user_connections = 300
key_buffer = 64M
myisam_sort_buffer_size = 64M
join_buffer_size = 2M
read_buffer_size = 2M
sort_buffer_size = 3M
table_cache = 1500
thread_cache_size = 286
wait_timeout = 28800
connect_timeout = 10
tmp_table_size = 256M
max_allowed_packet = 4M
max_connect_errors = 10
query_cache_limit = 2M
query_cache_size = 256M
query_cache_type = 1
query_prealloc_size = 16384
query_alloc_block_size = 16384
log-slow-queries = /var/log/mysql_slow_query_log
long_query_time = 4


[mysqld_safe]
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 128M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M



Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 11:22 pm 
Newbie

Joined: Wed Dec 13, 2006 8:12 pm
Posts: 7
Location: Minneapolis, MN, USA
I'll include log file entries you should be seeing if hibernate.cfg.xml and c3p0.properties are loading properly. That and the proper method to call to load hibernate.cfg.xml properly. I just have to get back to work. So, it'll be a day or two with the weekend.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.