0

I have some troubles to fix connection leaks in our developement enviroment.

Im using: Apache Tomcat 8.5 server with:

  • commons-dbcp2-2.1.1.jar
  • commons-pool2.2.4.2.jar
  • ojdbc6.jar Oracle driver
  • Oracle client 12.1.0.2.0 64-bit

I have some resources declared as:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myApp">
  <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" logAbandoned="true" maxActive="20" maxIdle="10" maxWait="1000" name="user1" password="user1" removeAbandoned="true" removeAbandonedTimeout="120" type="javax.sql.DataSource" url="jdbc:oracle:thin:@192.168.197.53:1521:orcl11g" username="user1" factory="org.apache.commons.dbcp2.BasicDataSourceFactory"/>
  <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" logAbandoned="true" maxActive="20" maxIdle="20" maxWait="1000" name="user3" password="user3" removeAbandoned="true" removeAbandonedTimeout="120" type="javax.sql.DataSource" url="jdbc:oracle:thin:@192.168.197.53:1521:orcl11g" username="user3" factory="org.apache.commons.dbcp2.BasicDataSourceFactory"/>
  <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" logAbandoned="true" maxActive="20" maxIdle="10" maxWait="1000" name="user2" password="user2" removeAbandoned="true" removeAbandonedTimeout="120" type="javax.sql.DataSource" url="jdbc:oracle:thin:@192.168.197.53:1521:orcl11g" username="user2" factory="org.apache.commons.dbcp2.BasicDataSourceFactory"/>
</Context>

Every time I shut down/restart Tomcat server, all connections between DBCP pool and Oracle DB (11g) stay open. I guess Tomcat should take care of that....

Any idea how to solve this issue?

EDIT: It seems its somehow related with the developers enviroment. On some computers the connections are closed, but on others they stay opened. We are using the same DB, the same Oracle client, drivers and the same Tomcat servers.

bakus33
  • 115
  • 1
  • 2
  • 11
  • Do you mean if you stop Tomcat the connections are still there? That doesn't seem possible though they may be in the `CLOSE_WAIT` state. – stdunbar Aug 16 '18 at 21:31
  • Thats right. When I check sessions in Oracle, connections are still there, even though Tomcat has stopped. – bakus33 Aug 17 '18 at 09:00
  • 1
    I don't think that this is a Tomcat issue per se. Once the operating system process exits (i.e. the JVM running Tomcat) the socket connection is closed and there isn't any way for Tomcat or the JVM to hold on to the connection. But it sounds like something else is getting in the way. I would look at tuning the network parameters on the database side. [This posting](https://www.infolob.com/detecting-dead-oracle-database-connections/) indicates that the default time out is **two hours** so hopefully you can tune it for a better timeout. – stdunbar Aug 17 '18 at 15:58
  • Thank you for your link, its useful, but not really the solution, its more like a workaround. I am going to check if NetBeans could be the reason. I know there were some issues about stopping tomcat via NetBeans... – bakus33 Aug 20 '18 at 13:51
  • But if the process has stopped it cannot be Netbeans or Tomcat - there is something in your environment that is causing this - you've already proven that. Basic TCP/IP networking is that if a process exits then the operating system closes the connection. If the server thinks it's still open then there is something else going on. Again, it is not Tomcat, Netbeans, or Java. – stdunbar Aug 20 '18 at 14:41

0 Answers0