开发者

Tomcat connection pooling,idle connections,and connection creation

开发者 https://www.devze.com 2023-04-03 22:23 出处:网络
I have the following problem in a web application.When i leave the server on for some period for example 24 hours my app stops working.

I have the following problem in a web application.When i leave the server on for some period for example 24 hours my app stops working. I am using tomcat 7 and Connection pooling.My Database is MySQL.

I am getting the following exception:

  Communication link failure: java.io.EOFException, underlying cause: null ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at 
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1394) at 
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1538) at 
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929) at 
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167) at 
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278) at 
com.mysql.jdbc.Connection.execSQL(Connection.java:2251) at 
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586) at 
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStat
ement.java:96) at 
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStat
ement.java:96) at configuration.Login.doPost(Login.java:104) at 
javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at 
javax.servlet.http.HttpServlet.serv开发者_高级运维ice(HttpServlet.java:722) at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.jav
a:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403) at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301) at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java
:162) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java
:140) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) 
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at 
java.lang.Thread.run(Thread.java:662) ** END NESTED EXCEPTION **

I find out that this error occurred when the pooled connections for some reason after some period of time have been closed maybe due to time limit or something. My question is that connection pool shouldn't have created new connections when there are no connections into the pool ?The error is not caused by traffic because no one uses the application at the moment.How can I fix this error ?When the app is deployed I start using the app,pooled connections are being created.These connections are idle?Is there a way these connections wont be closed?But if i can do that don't I waste connections from other applications on the server?

Also if I keep trying to use the application after some time new connections are created and the app starts working.But this isn't normal.......

//Edit if i manualy close all active connections from MYSQL Admin this error appears again.


There are background connections.

How do you define your pool?

Here are some useful options.

minEvictableIdleTimeMillis="60000"maxActive="100" minIdle="10" maxIdle="50" maxWait="10000"
    removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"

And add in the url the autoReconnect=true

url="jdbc:mysql://localhost:3306/db?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号