2

we have move the code on new server, as previously we are using the tomcat6 but on new system installed the tomcat7. so we are getting the below error, i did the googling and make the changes but still getting same error. the error as below.

Sep 21, 2014 6:15:14 PM org.apache.tomcat.jdbc.pool.ConnectionPool abandon
WARNING: Connection has been abandoned PooledConnection[com.mysql.jdbc.JDBC4Connection@2365914f]:java.lang.Exception
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getThreadDump(ConnectionPool.java:1063)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:780)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:619)
        at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
        at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
        at com.fstl.resellermg.util.DbUtils.getConnection(DbUtils.java:34)
        at com.fstl.resellermg.bo.LeadExtBO.getListUploadStatus(LeadExtBO.java:1350)
        at com.fstl.resellermg.servlet.GetLeadCountByUserName.doPost(GetLeadCountByUserName.java:56)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:193)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

My context.xml configuration is

<Context>
<Resource name="jdbc/testDB"
auth="Container"
type="javax.sql.DataSource"
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/xxx"
validationQuery="SELECT 1"
validationInterval="30000"
maxWait="1000"
removeAbandoned="true"
initialSize="10"
maxActive="100"
maxIdle="50"
minIdle="10"
suspectTimeout="60"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="60000"
testOnBorrow="true"
removeAbandonedTimeout="60"
logAbandoned="true"/>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

</Context>
rajub
  • 320
  • 1
  • 5
  • 17
  • I've found that using connection pool software with better error messages helps me diagnose these types of things. I'm using Hikari CP and find it to be more useful. That said, I fully agree with the approach by @kaqqao (+1 for that answer). – riddle_me_this Mar 25 '15 at 17:49
  • This is the solution you are looking for - https://stackoverflow.com/questions/13129070/webapp-tomcat-jdbc-pooled-db-connection-throwing-abandon-exception – Sunil Kumar Aug 04 '17 at 06:07

2 Answers2

6

The error clearly says the connection was abandoned. This means one of two things. Either somewhere in your code, you're not closing the connection properly, or you have a long running query that exceeds the timeout (a minute in your case) so Tomcat wrongly believes it's been abandoned. Make your DB log slow queries, or profile your app to figure out if the latter is the case.

kaqqao
  • 12,984
  • 10
  • 64
  • 118
  • Hi sir thanks for your quick response How it was working in tomcat6 without any failure. – rajub Sep 22 '14 at 18:42
  • Maybe your server spec, network layout or firewall rules changed increasing the latency and hitting timeout. Maybe your previous pool wasn't killing abandoned connections. Could be a million things and without knowing the guts of your application, it will be near impossible to say, yet the error message is quite explicit about what is happening. But following my advice on logging slow queries and/or profiling should get you on the right track. You may want to simply try monitoring your pool usage using something like PSI Probe: https://code.google.com/p/psi-probe/ – kaqqao Sep 23 '14 at 07:56
-1

This is working with Tomcat 6 because that version doesn't include timeout functionality. That's why the query is running properly without a timeout.

Sean Mickey
  • 7,618
  • 2
  • 32
  • 58