You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Gemoets, Darren" <Da...@aquilent.com> on 2012/09/21 20:27:52 UTC

Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Hello, all.  I have a simple test program that opens a JDBC connection to a PostgreSQL database (using the Tomcat connection pool) and runs a simple query.  It uses connection/result closing code from the documentation.  The test program works fine standalone, but when I use it via an Axis2 web service, it seems to be causing abandoned connections.  After a few connections, it can't connect because there are no connections available because they're all abandoned.

I haven't done anything fancy with the service, the WSDL, the transport, or anything...in poking around I see some things that maybe look related like REUSE_HTTP_CLIENT and I also ran across this entry from StackOverflow<http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way> (http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way) that could be relevant, though not for the novice Axis2 user.

Any thoughts?  Any more info needed?

Thank you.

Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by robert lazarski <ro...@gmail.com>.
On Fri, Sep 21, 2012 at 7:33 PM, Deepal jayasinghe <de...@gmail.com> wrote:
> I guess main issue is not closing the connections (or rather not reusing
> them). So any approach that helps you to reuse the connections would
> help to resolve the issue. In the article I mentioned an approach, but
> there could be many. One thing you need to make sure is depending on the
> request scope you might have a large number of services instances so
> does the DB connections.
>

In practice any pool and db can support around 100 connections on
vanilla hardware with auto re-use and commits. Put your close()
statement in a finally block and that may be all you need to do.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by "Gemoets, Darren" <Da...@aquilent.com>.
I was able to get my web service working by storing the DataSource (instead of the connection) in the ConfigurationContext and just getting connections from the persisted DataSource each time the service is invoked.

It turns out someone else did something similar on 12/30/2011-- http://mail-archives.apache.org/mod_mbox/axis-java-user/201112.mbox/%3CCB2355CB.3606E%25zeng@adobe.com%3E

Thanks for the replies.

Darren

-----Original Message-----
From: Deepal jayasinghe [mailto:deepalk@gmail.com] 
Sent: Friday, September 21, 2012 18:34
To: java-user@axis.apache.org
Subject: Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

I guess main issue is not closing the connections (or rather not reusing them). So any approach that helps you to reuse the connections would help to resolve the issue. In the article I mentioned an approach, but there could be many. One thing you need to make sure is depending on the request scope you might have a large number of services instances so does the DB connections.

Deepal
>> This might give you some light.
>>
>> http://www.developer.com/db/article.php/3735771/Exposing-a-Database-a
>> s-a-Web-Service.htm
>>
>> Deepal
> Darren said that he is using a connection pool, not the DriverManager 
> API. In that case, you manage connections differently than the pattern 
> shown in your article. If you use that pattern together with a 
> container managed connection pool, then it becomes an anti-pattern.
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by Deepal jayasinghe <de...@gmail.com>.
I guess main issue is not closing the connections (or rather not reusing
them). So any approach that helps you to reuse the connections would
help to resolve the issue. In the article I mentioned an approach, but
there could be many. One thing you need to make sure is depending on the
request scope you might have a large number of services instances so
does the DB connections.

Deepal
>> This might give you some light.
>>
>> http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as-a-Web-Service.htm
>>
>> Deepal
> Darren said that he is using a connection pool, not the DriverManager
> API. In that case, you manage connections differently than the pattern
> shown in your article. If you use that pattern together with a
> container managed connection pool, then it becomes an anti-pattern.
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by "Gemoets, Darren" <Da...@aquilent.com>.
Or maybe another possibility is to store the DataSource in the ConfigurationContext instead of the connection and just get connections from the persisted DataSource each time the service is invoked.  I'll give it a try next week.  Thanks again.

-----Original Message-----
From: Gemoets, Darren [mailto:Darren.Gemoets@aquilent.com] 
Sent: Friday, September 21, 2012 15:04
To: java-user@axis.apache.org
Subject: RE: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Interesting...I had run across ServiceLifeCycle somewhere along the way and wondered if that should be part of my solution.  But I guess what happens with that approach is that it persists a single DB connection for the entire lifetime of the web service-- that is, until either Tomcat is restarted or the Axis service is un/re-deployed...right?  Like Andreas implies, that's sort of counter to the idea of a connection pool.

That said, if the ServiceLifeCycle approach obviates the need for a connection pool, yet provides many the same advantages (and more importantly-- works), then I guess I should ditch the connection pool and adopt the persistent DB connection.  I do also wonder about keeping the DB connection open indefinitely.  Intuitively, it seems like something would time out or ultimately the connection would go bad in some way-- with no recourse other than to restart Tomcat or redeploy the service.  Maybe before each query I test the connection for validity and create a new one if it's bad, saving it in the ConfigurationContext?

Anyway, thank you for the responses.

Darren

-----Original Message-----
From: Andreas Veithen [mailto:andreas.veithen@gmail.com] 
Sent: Friday, September 21, 2012 14:52
To: java-user@axis.apache.org
Subject: Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

> This might give you some light.
>
> http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as
> -a-Web-Service.htm
>
> Deepal

Darren said that he is using a connection pool, not the DriverManager API. In that case, you manage connections differently than the pattern shown in your article. If you use that pattern together with a container managed connection pool, then it becomes an anti-pattern.

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by "Gemoets, Darren" <Da...@aquilent.com>.
Interesting...I had run across ServiceLifeCycle somewhere along the way and wondered if that should be part of my solution.  But I guess what happens with that approach is that it persists a single DB connection for the entire lifetime of the web service-- that is, until either Tomcat is restarted or the Axis service is un/re-deployed...right?  Like Andreas implies, that's sort of counter to the idea of a connection pool.

That said, if the ServiceLifeCycle approach obviates the need for a connection pool, yet provides many the same advantages (and more importantly-- works), then I guess I should ditch the connection pool and adopt the persistent DB connection.  I do also wonder about keeping the DB connection open indefinitely.  Intuitively, it seems like something would time out or ultimately the connection would go bad in some way-- with no recourse other than to restart Tomcat or redeploy the service.  Maybe before each query I test the connection for validity and create a new one if it's bad, saving it in the ConfigurationContext?

Anyway, thank you for the responses.

Darren

-----Original Message-----
From: Andreas Veithen [mailto:andreas.veithen@gmail.com] 
Sent: Friday, September 21, 2012 14:52
To: java-user@axis.apache.org
Subject: Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

> This might give you some light.
>
> http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as
> -a-Web-Service.htm
>
> Deepal

Darren said that he is using a connection pool, not the DriverManager API. In that case, you manage connections differently than the pattern shown in your article. If you use that pattern together with a container managed connection pool, then it becomes an anti-pattern.

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by Andreas Veithen <an...@gmail.com>.
> This might give you some light.
>
> http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as-a-Web-Service.htm
>
> Deepal

Darren said that he is using a connection pool, not the DriverManager
API. In that case, you manage connections differently than the pattern
shown in your article. If you use that pattern together with a
container managed connection pool, then it becomes an anti-pattern.

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by Deepal jayasinghe <de...@gmail.com>.
On 9/21/2012 2:27 PM, Gemoets, Darren wrote:
>
> Hello, all.  I have a simple test program that opens a JDBC connection
> to a PostgreSQL database (using the Tomcat connection pool) and runs a
> simple query.  It uses connection/result closing code from the
> documentation.  The test program works fine standalone, but when I use
> it via an Axis2 web service, it seems to be causing abandoned
> connections.  After a few connections, it can't connect because there
> are no connections available because they're all abandoned.
>
>  
>
> I haven't done anything fancy with the service, the WSDL, the
> transport, or anything...in poking around I see some things that maybe
> look related like REUSE_HTTP_CLIENT and I also ran across this entry
> from StackOverflow
> <http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way>
> (http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way)
> that could be relevant, though not for the novice Axis2 user.
>
>  
>
> Any thoughts?  Any more info needed?
>
>  
>
> Thank you.
>
This might give you some light.

http://www.developer.com/db/article.php/3735771/Exposing-a-Database-as-a-Web-Service.htm

Deepal

Re: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by robert lazarski <ro...@gmail.com>.
On Fri, Sep 21, 2012 at 3:27 PM, Gemoets, Darren
<Da...@aquilent.com> wrote:
> Hello, all.  I have a simple test program that opens a JDBC connection to a
> PostgreSQL database (using the Tomcat connection pool) and runs a simple
> query.  It uses connection/result closing code from the documentation.  The
> test program works fine standalone, but when I use it via an Axis2 web
> service, it seems to be causing abandoned connections.  After a few
> connections, it can’t connect because there are no connections available
> because they’re all abandoned.
>
>
>
> I haven’t done anything fancy with the service, the WSDL, the transport, or
> anything...in poking around I see some things that maybe look related like
> REUSE_HTTP_CLIENT and I also ran across this entry from StackOverflow
> (http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way)
> that could be relevant, though not for the novice Axis2 user.
>
>
>
> Any thoughts?  Any more info needed?
>
>
>
> Thank you.

Offtopic ... but you sure seem like you are somehow not executing
close() on your db connections. Hard to see how axis2 is part of the
problem without logs, stacktraces or code.  Standalone would shut down
the pool so you might have glossed over some close() issue.

- R

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Darren

did you configure your transports to use KeepAlive
<parameter name="PROTOCOL">HTTP/1.1</parameter>
?

In the meanwhile take a look at DBCP examples for impelementing database pooling characteristics
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/
http://commons.apache.org/dbcp/
Martin
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehiene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


From: Darren.Gemoets@aquilent.com
To: java-user@axis.apache.org
Subject: Problems using Tomcat 7 connection pool to PostgreSQL with Axis2
Date: Fri, 21 Sep 2012 18:27:52 +0000









Hello, all.  I have a simple test program that opens a JDBC connection to a PostgreSQL database (using the Tomcat connection pool) and runs a simple query.  It uses connection/result closing code from the documentation.  The test program
 works fine standalone, but when I use it via an Axis2 web service, it seems to be causing abandoned connections.  After a few connections, it can’t connect because there are no connections available because they’re all abandoned.
 
I haven’t done anything fancy with the service, the WSDL, the transport, or anything...in poking around I see some things that maybe look related like REUSE_HTTP_CLIENT and I also ran across

this entry from StackOverflow (http://stackoverflow.com/questions/1093888/how-can-i-test-if-my-connection-pool-is-working-in-a-correct-way)
 that could be relevant, though not for the novice Axis2 user.
 
Any thoughts?  Any more info needed?
 
Thank you.