tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Tomcat and MySQL sync problems
Date Mon, 29 Jan 2007 16:05:34 GMT
It appears your code is holding on to a connection to the database.  Bad
design practice.  Review your code for any place that might keep hold of
a connection between requests and make sure the connection is closed. 

Also, If you haven't done so yet, use a database connection pool.  If
using tomcat's built-in one, set testOnBorrow to "true" and set
validationQuery to something simple like "select 1".  The idea being
that the connections will be validated just before they are borrowed and
used, closed and recreated if they fail.

Lastly, please avoid autoReconnect=true in the connection url as the
first query will still error out.  There is documentation on mysql's
site recommending this option not be used.

--David

Scott Purcell wrote:

>If I remember correctly, MySQL basically disconnects and shutdowns after
>a certain amount of time. I remember doing something with a
>"reload="true" in the datasource to prevent this.
>
>Hopefully someone else may clue you in better, but you may want to check
>the datasource props and see if this is valid.
>
>
>Scott
>
>-----Original Message-----
>From: Chris Long [mailto:chlong2@gmail.com] 
>Sent: Monday, January 29, 2007 8:54 AM
>To: users@tomcat.apache.org
>Subject: Tomcat and MySQL sync problems
>
>Hello,
>
>I'm having a problem where it seems Tomcat and MySQL go out of sync and
>I am
>no longer able to connect to the MySQL database.  The only way I've
>found to
>be able to reconnect to my database is to restart Tomcat.  This
>generally
>seems to happen some time over the course of the night and I notice the
>problem when I check on things in the morning, but it doesn't seem to
>happen
>every time.
>
>Does anyone have any idea what may be causing this and how to fix it?
>
>Here is a list of what I'm using:
>
>Tomcat 5.5.17
>MySQL 14.12
>Hibernate 3.2
>mysql-connector-java-5.0.4
>JAVA 1.5
>Windows XP Pro
>
>
>[Jan 29 2007 (Mon)9:30:56 EST] ERROR [http-8888-Processor20](
>org.hibernate.util.JDBCExceptionReporter) - No operations allowed after
>connection closed.Connection was implicitly closed due to underlying
>exception/error:
>
>
>** BEGIN NESTED EXCEPTION **
>
>com.mysql.jdbc.CommunicationsException
>MESSAGE: Communications link failure due to underlying exception:
>
>** BEGIN NESTED EXCEPTION **
>
>java.net.SocketException
>MESSAGE: Software caused connection abort: socket write error
>
>STACKTRACE:
>
>java.net.SocketException: Software caused connection abort: socket write
>error
>    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:2637)
>    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
>    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
>    at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
>    at com.mysql.jdbc.PreparedStatement.executeInternal(
>PreparedStatement.java:1153)
>    at
>com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java
>:1266)
>    at
>org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java
>:186)
>    at org.hibernate.loader.Loader.getResultSet(Loader.java:1778)
>    at org.hibernate.loader.Loader.doQuery(Loader.java:662)
>    at
>org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
>Loader.java:224)
>    at org.hibernate.loader.Loader.doList(Loader.java:2211)
>    at
>org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
>    at org.hibernate.loader.Loader.list(Loader.java:2090)
>    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
>    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 org.hibernate.impl.AbstractQueryImpl.uniqueResult(
>AbstractQueryImpl.java:804)
>    at
>com.tne.nres.projectTracker.ProjectTrackerServlet.validateUser(Unknown
>Source)
>    at com.tne.nres.projectTracker.ProjectTrackerServlet.doPost(Unknown
>Source)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>ApplicationFilterChain.java:252)
>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
>ApplicationFilterChain.java:173)
>    at org.apache.catalina.core.StandardWrapperValve.invoke(
>StandardWrapperValve.java:213)
>    at org.apache.catalina.core.StandardContextValve.invoke(
>StandardContextValve.java:178)
>    at org.apache.catalina.core.StandardHostValve.invoke(
>StandardHostValve.java:126)
>    at org.apache.catalina.valves.ErrorReportValve.invoke(
>ErrorReportValve.java:105)
>    at org.apache.catalina.core.StandardEngineValve.invoke(
>StandardEngineValve.java:107)
>    at org.apache.catalina.connector.CoyoteAdapter.service(
>CoyoteAdapter.java:148)
>    at
>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
>:869)
>    at
>org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc
>essConnection
>(Http11BaseProtocol.java:664)
>    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
>PoolTcpEndpoint.java:527)
>    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
>LeaderFollowerWorkerThread.java:80)
>    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
>ThreadPool.java:684)
>    at java.lang.Thread.run(Thread.java:595)
>
>
>** END NESTED EXCEPTION **
>
>
>
>Last packet sent to the server was 16 ms ago.
>
>STACKTRACE:
>
>com.mysql.jdbc.CommunicationsException: Communications link failure due
>to
>underlying exception:
>
>** BEGIN NESTED EXCEPTION **
>
>java.net.SocketException
>MESSAGE: Software caused connection abort: socket write error
>
>STACKTRACE:
>
>java.net.SocketException: Software caused connection abort: socket write
>error
>    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:2637)
>    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
>    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
>    at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
>    at com.mysql.jdbc.PreparedStatement.executeInternal(
>PreparedStatement.java:1153)
>    at
>com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java
>:1266)
>    at
>org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java
>:186)
>    at org.hibernate.loader.Loader.getResultSet(Loader.java:1778)
>    at org.hibernate.loader.Loader.doQuery(Loader.java:662)
>    at
>org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
>Loader.java:224)
>    at org.hibernate.loader.Loader.doList(Loader.java:2211)
>    at
>org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
>    at org.hibernate.loader.Loader.list(Loader.java:2090)
>    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
>    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 org.hibernate.impl.AbstractQueryImpl.uniqueResult(
>AbstractQueryImpl.java:804)
>    at
>com.tne.nres.projectTracker.ProjectTrackerServlet.validateUser(Unknown
>Source)
>    at com.tne.nres.projectTracker.ProjectTrackerServlet.doPost(Unknown
>Source)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>ApplicationFilterChain.java:252)
>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
>ApplicationFilterChain.java:173)
>    at org.apache.catalina.core.StandardWrapperValve.invoke(
>StandardWrapperValve.java:213)
>    at org.apache.catalina.core.StandardContextValve.invoke(
>StandardContextValve.java:178)
>    at org.apache.catalina.core.StandardHostValve.invoke(
>StandardHostValve.java:126)
>    at org.apache.catalina.valves.ErrorReportValve.invoke(
>ErrorReportValve.java:105)
>    at org.apache.catalina.core.StandardEngineValve.invoke(
>StandardEngineValve.java:107)
>    at org.apache.catalina.connector.CoyoteAdapter.service(
>CoyoteAdapter.java:148)
>    at
>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
>:869)
>    at
>org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc
>essConnection
>(Http11BaseProtocol.java:664)
>    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
>PoolTcpEndpoint.java:527)
>    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
>LeaderFollowerWorkerThread.java:80)
>    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
>ThreadPool.java:684)
>    at java.lang.Thread.run(Thread.java:595)
>
>
>** END NESTED EXCEPTION **
>
>
>
>Last packet sent to the server was 16 ms ago.
>    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
>    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
>    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
>    at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
>    at com.mysql.jdbc.PreparedStatement.executeInternal(
>PreparedStatement.java:1153)
>    at
>com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java
>:1266)
>    at
>org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java
>:186)
>    at org.hibernate.loader.Loader.getResultSet(Loader.java:1778)
>    at org.hibernate.loader.Loader.doQuery(Loader.java:662)
>    at
>org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
>Loader.java:224)
>    at org.hibernate.loader.Loader.doList(Loader.java:2211)
>    at
>org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
>    at org.hibernate.loader.Loader.list(Loader.java:2090)
>    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:388)
>    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 org.hibernate.impl.AbstractQueryImpl.uniqueResult(
>AbstractQueryImpl.java:804)
>    at
>com.tne.nres.projectTracker.ProjectTrackerServlet.validateUser(Unknown
>Source)
>    at com.tne.nres.projectTracker.ProjectTrackerServlet.doPost(Unknown
>Source)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
>ApplicationFilterChain.java:252)
>    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
>ApplicationFilterChain.java:173)
>    at org.apache.catalina.core.StandardWrapperValve.invoke(
>StandardWrapperValve.java:213)
>    at org.apache.catalina.core.StandardContextValve.invoke(
>StandardContextValve.java:178)
>    at org.apache.catalina.core.StandardHostValve.invoke(
>StandardHostValve.java:126)
>    at org.apache.catalina.valves.ErrorReportValve.invoke(
>ErrorReportValve.java:105)
>    at org.apache.catalina.core.StandardEngineValve.invoke(
>StandardEngineValve.java:107)
>    at org.apache.catalina.connector.CoyoteAdapter.service(
>CoyoteAdapter.java:148)
>    at
>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
>:869)
>    at
>org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.proc
>essConnection
>(Http11BaseProtocol.java:664)
>    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
>PoolTcpEndpoint.java:527)
>    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
>LeaderFollowerWorkerThread.java:80)
>    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
>ThreadPool.java:684)
>    at java.lang.Thread.run(Thread.java:595)
>
>
>** END NESTED EXCEPTION **
>
>Thanks,
>
>Christopher Long
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message