TomcatExpert

Tomcat-jdbc pooling not detecting dead connections

We recently migrated to using the apache tomcat jdbc connection pooling.

We are using v1.1.0.1 of the connection pooling mechanism with tomcat 6.0.33 on Oracle 10g

Our connection pools are configured as follows:

<Resource name="jdbc/testPool" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
          url="jdbc:oracle:thin:@192.168.1.11:1521:TESTDB"
              username="user" password="xxx" initialSize="2" maxActive="5" minIdle="1" maxIdle="2"
              maxWait="1" removeAbandoned="true" removeAbandonedTimeout="15"  logAbandoned="true"    abandonWhenPercentageFull="100"  jdbcInterceptors="ResetAbandonedTimer"/>

The application works fine in normal situations but we noticed the following problems:-

a) When the ResetAbandonedTimer kicks in the connection itself does not get discarded and the app when it requests a new connection gets handed the connection that was already killed by the ResetAbandonedTimer mechanism .

b) We were also able to easily reproduce the above issue by running the application and then killing the idle connection from the oracle end. I would expect that if a connection gets killed from the oracle end the connection pool should detect it and log and discard the connection. However the apache-tomcat-jdbc pooling mechanism as configured in my setup does not seem to detect this condition at all. It waits silently till the app requests another connection and returns the dead connection to the app which of course fails as soon as the app tries to use the connection.

asked by san9jay

question

add

testOnBorrow="true"

validationQuery="select 1 from dual"

in order to validate your connections

answer

answered by fhanik on May 10, 2012 08:39 AM

Filip Hanik is a Senior Software Engineer for the SpringSource Division of VMware, Inc. (NYSE: VMW) and a key participant in the company's Apache Tomcat initiatives. Filip brings 15 years of extensive experience in architecture, design and development of distributed application frameworks and containers and is recognized for his top-quality system development skills and continuous participation of Open Source development projects. Filip is an Apache Software Foundation member and a committer to the Apache Tomcat project where he is a leading authority on Tomcat clustering and a key contributor to the core of the platform. Filip has made contributions to software initiatives for Walmart.com, Sony Music, France Telecom and has held a variety of senior software engineering positions with technology companies in both the United States and Sweden. He received his education at Chalmers University of Technology in Gothenburg, Sweden where he majored in Computer Science and Computer Engineering.

Comments

alan51

I read this article because it is not including worthless information passguide 1z0-436
. The author clearly describes the information. Thank you for sharing this types article. This will be very beneficiary for the readers passguide 300-460
.

Unless you know something

Unless you know something about scripts, it's quite hard to detect and solve any type of problem your software might have at some point. Once you understand how your apps work, you can try out the quickbooks accounting software vashon wa, especially if you own a business. Technology can really make things easier.

This is very academic content

This is very academic content and published well for something different click to investigate. It's awesome to see that some people still understand creating a quality post!

David

buy retweets These things are very important, good think so - I think so too... buy twitter followers

Could you please explain what

Could you please explain what you mean under the dead connection being detected out of the box? I looked through this and similar posts but to tell the truth I didn't understand entirely everything. I am sorry for my incompetence.
You just pay and we are writing an essays instead of you.

 

 

reply

I am no computer geek but this website has helped me to understand more on the different concepts of operating systems and fixing many issues in the OS and servers. I hope that you guys will be able to come up with a solution for this issue also. order cheese curds online

SSL/JDBC issue betweeb Tomcat and Oracle

Hello,

I'm trying to use SSL for encryption and server authentication between Oracle 11.2 with Tomcat 7.0.67 with Java 1.8 installed on Redhat 6.7 server. Currently, I'm using this document as a guide: http://www.oracle.com/technetwork/topics/wp-oracle-jdbc-thin-ssl-130128.pdf

So I have this configuration in context.xml file:

factory="org.apache.naming.factory.BeanFactory"
name="jdbc/DB" auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
driverClass="oracle.jdbc.OracleDriver"
jdbcurl ="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=servername)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=servicename)))");

In the catalina.sh file I have:

#JAVA_OPTS="-Djavax.net.ssl.trustStore=/opt/wallet/cwallet.sso -Djavax.net.ssl.trustStoreType=SSO -Doracle.net.ssl_cipher_suites=TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA"

In the java security file I added this to the end of the line:

security.provider.9=oracle.security.pki.OraclePKIProvider

Here are the errors I receive when trying to connect to the db:

Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:439)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:454)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:693)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:251)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
... 13 more
Caused by: oracle.net.ns.NetException: Unable to initialize ssl context.
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:327)
at oracle.net.nt.TcpsNTAdapter.connect(TcpsNTAdapter.java:119)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:405)
... 18 more
Caused by: oracle.net.ns.NetException: Unable to initialize the trust store.
at oracle.net.nt.CustomSSLSocketFactory.getTrustManagerArray(CustomSSLSocketFactory.java:415)
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:311)
... 21 more
Caused by: java.security.KeyStoreException: SSO not found
at java.security.KeyStore.getInstance(KeyStore.java:851)
at oracle.net.nt.CustomSSLSocketFactory.getTrustManagerArray(CustomSSLSocketFactory.java:403)
... 22 more
Caused by: java.security.NoSuchAlgorithmException: SSO KeyStore not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
at java.security.Security.getImpl(Security.java:695)
at java.security.KeyStore.getInstance(KeyStore.java:848)

Any help would be appreciated. Thanks.

workaround

adding the following to the connection pool config is a workaround but I would think a dead connection should be detected out of the box. the

testOnBorrow="true" validationQuery="SELECT 1 from dual" validationInterval="30000"

Regards

/sanjay

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.