- This topic has 2 replies, 2 voices, and was last updated 16 years, 7 months ago by Mork.
-
AuthorPosts
-
MorkParticipantI have a relatively simple Dao application that runs on both Windows and Linux with MySQL 5.0.45, and 5.1.6 of the Connector/J JDBC driver (tried all versions of the JDBC driver).
What’s happening is that after a period of inactivity, I try to do a simple login and I get an error stack like the one below.
The stack trace below says I should use autoReconnect=true, which I already have in my Hibernate config file.
I’m using simple Dao code MyEclipse generated. I can post that too, but it’s very generic. I’ve seen lots of problems like the one I’m reporting here, but no clear solution.
I also have all the timeout settings in the My.cnf (MySQL configuration file) commented out.
Any suggestions you can give me about what I might try would be greatly appreciated.
Maybe I need to create a brand new connection each time the Hibernate code runs, but I’m not sure how to do this…
The only solution so far is to reboot Tomcat every day!
Thanks in advance.
M
———————————————————————
First, though, here’s my Hibernate config file:
<?xml version=’1.0′ encoding=’UTF-8′?>
<!DOCTYPE hibernate-configuration PUBLIC
“-//Hibernate/Hibernate Configuration DTD 3.0//EN”
“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”><!– Generated by MyEclipse Hibernate Tools. –>
<hibernate-configuration><session-factory>
<property name=”connection.username”>users</property>
<property name=”connection.url”>
jdbc:mysql://localhost:3306/users
</property>
<property name=”dialect”>
org.hibernate.dialect.MySQLDialect
</property>
<property name=”connection.autoReconnect”>true</property>
<property name=”connection.autoReconnectForPools”>true</property>
<property name=”connection.is-connection-validation-required”>true</property>
<property name=”hibernate.show.sql”>true</property>
<property name=”myeclipse.connection.profile”>MySQL Visitors/property>
<property name=”connection.password”>adfa##dfadf</property>
<property name=”connection.driver_class”>
com.mysql.jdbc.Driver
</property>
<mapping
resource=”testProject/Uservisithistory.hbm.xml” />
<mapping resource=”testProject/Users.hbm.xml” /></session-factory>
</hibernate-configuration>
——————————————————
The stack trace that occurs after some timeout period…
com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was58156 seconds ago.The last packet sent successfully to the server was 58156 seconds ago, which 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 com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3246)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1917)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at testProject.UsersDAO.findByProperty(UsersDAO.java:125)
at testProject.UsersDAO.findByUsrLogin(UsersDAO.java:176)
at testProject.ValidateLogin.validate(ValidateLogin.java:51)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:121)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
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.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
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:3227)
… 42 more** END NESTED EXCEPTION **
Riyad KallaMemberMoving to OT > Soft Dev, this is a Hibernate question (not specific to ME).
Mork I don’t have any suggestions for you besides checking the Hibernate forums or Googling, I think every Hibernate dev runs across this at some point with long-running apps, I know a few friends of mine using Hibernate were hit by this as well years ago.
MorkParticipantThanks, I think I figured it out.
MySQL Timeout issue (8 hrs., by default) that needs to be addressed.
Thanks for your reply….
-
AuthorPosts