tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Deller <andreas.del...@ergon.ch>
Subject Re: Tomcat and MySQL sync problems
Date Mon, 29 Jan 2007 15:02:31 GMT
Hi

We had a simliar problem with Oracle and Tomcat 4.1.30 and a firewall
in between and I don't remember the exact error message, so I'm not sure
if this helps:
The problem was that Tomcat held the DB connection open infinitely, and the
firewall after a while decided it wanted to drop the connection. For a new
request, Tomcat just used one of its connections from its pool and took a long
time to recognize that the firewall had closed its connection.

Solution: set an explicit timeout in server.xml:

<Context>
...
	<Resource name="my-database" auth="Container"
		type="javax.sql.DataSource" description="User repository"
	/>
	<ResourceParams name="my-database">
<parameter><name>timeBetweenEvictionRunsMillis</name><value>60000</value></parameter>
<parameter><name>numTestsPerEvictionRun</name><value>5</value></parameter>
<parameter><name>minEvictableIdleTimeMillis</name><value>600000</value></parameter>
	</ResourceParams>
</Context>

	Andy

Chris Long wrote:
> 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.processConnection

> 
> (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.processConnection

> 
> (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.processConnection

> 
> (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
> 

Mime
View raw message