You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by jkraushaar <jo...@doubleslash.de> on 2014/10/08 08:12:53 UTC

Pooling with PostgreSQL and Karaf

Hi there,

I like to set up a PostgreSQL data source in Karaf. In the Karaf-Tutorial a
org.postgresql.ds.PGPoolingDataSource is used (see
https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-postgres.xml).
On the other hand PostgreSQL recommends to not use the pooled data source
provided by them. Instead they refer to Apache Commons DBCP (see
http://jdbc.postgresql.org/documentation/93/ds-ds.html). Also our custom
Karaf assembly already has Commons DBCP 1.4 installed.

What is your experience in the past? Is it save to use PGPoolingDataSource
or should we use DBCP to create a connection pool instead?

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Pooling with PostgreSQL and Karaf

Posted by Rajbir Saini <ra...@yahoo.com>.
If you are using Karaf 3.0.1, you can use the jdbc commands to create 
the data source. There is a generic data source type and I think it uses 
Apache Common DBCP.

Thanks,

Raj

On Wednesday 08 October 2014 11:42 AM, jkraushaar wrote:
> Hi there,
>
> I like to set up a PostgreSQL data source in Karaf. In the Karaf-Tutorial a
> org.postgresql.ds.PGPoolingDataSource is used (see
> https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-postgres.xml).
> On the other hand PostgreSQL recommends to not use the pooled data source
> provided by them. Instead they refer to Apache Commons DBCP (see
> http://jdbc.postgresql.org/documentation/93/ds-ds.html). Also our custom
> Karaf assembly already has Commons DBCP 1.4 installed.
>
> What is your experience in the past? Is it save to use PGPoolingDataSource
> or should we use DBCP to create a connection pool instead?
>
> Regards
> Jochen
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>


Re: Pooling with PostgreSQL and Karaf

Posted by jkraushaar <jo...@doubleslash.de>.
Hi there,

I solved the problem by replacing "WHEN_EXHAUSTED_BLOCK" with "1". It seems
that Blueprint cannot resolve WHEN_EXHAUSTED_BLOCK to the constant defined
by GenericObjectPool.

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692p4035731.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Pooling with PostgreSQL and Karaf

Posted by jkraushaar <jo...@doubleslash.de>.
Hi JB,

I checked with 

la | grep -i DBCP 
and 
la | grep -i Pool

and only one DBCP and Pool bundle is installed. I also checked with
find-class GenericObjectPool and the class is only found in the DBCP, Pool
and my data source bundle. DBCP and my data source load the class from the
Pool bundle.

Header information from the Pool bundle:

Commons Pool (113)
------------------
Specification-Title = Commons Pool
Archiver-Version = Plexus Archiver
Tool = Bnd-1.43.0
Specification-Version = 1.6
Specification-Vendor = The Apache Software Foundation
Implementation-Version = 1.6
Build-Jdk = 1.6.0_29
Implementation-Vendor-Id = org.apache
Created-By = Apache Maven Bundle Plugin
Implementation-Title = Commons Pool
Manifest-Version = 1.0
Implementation-Build = UNKNOWN_BRANCH@r??????; 2012-01-04 10:31:47-0500
Bnd-LastModified = 1325691112817
X-Compile-Target-JDK = 1.5
Include-Resource =
META-INF/LICENSE.txt=LICENSE.txt,META-INF/NOTICE.txt=NOTICE.txt
Built-By = ggregory
X-Compile-Source-JDK = 1.5
Implementation-Vendor = The Apache Software Foundation

Bundle-Vendor = The Apache Software Foundation
Bundle-Name = Commons Pool
Bundle-DocURL = http://commons.apache.org/pool/
Bundle-Description = Commons Object Pooling Library
Bundle-SymbolicName = org.apache.commons.pool
Bundle-Version = 1.6.0
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2

Export-Package = 
	org.apache.commons.pool.impl;version=1.6,
	org.apache.commons.pool;version=1.6

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692p4035712.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Pooling with PostgreSQL and Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Jochen,

thanks for the update.

Can you check if you don't have multiple dbcp/pools bundles installed 
(different versions) ?

Especially, the jdbc:create command can install bundles for you (you 
have an option to avoid this).

Regards
JB

On 10/08/2014 10:39 AM, jkraushaar wrote:
> Hi JB,
>
> when I try to use the generic data source, I get the following exception
> from blueprint:
>
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
> find a matching constructor on class
> org.apache.commons.pool.impl.GenericObjectPool for arguments [null, 8,
> WHEN_EXHAUSTED_BLOCK, -1, 8, 2, false, false, -1, 3, 5000, false, -1, true]
> when instanciating bean connectionPool
>
> The data source is installed as bundle. We use Commons DBCP 1.4 and Commons
> Pool 1.6. According to the javadoc, there should be a constructor with this
> arguments:
> http://commons.apache.org/proper/commons-pool/api-1.6/org/apache/commons/pool/impl/GenericObjectPool.html
>
> Regards
> Jochen
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692p4035705.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Pooling with PostgreSQL and Karaf

Posted by jkraushaar <jo...@doubleslash.de>.
Hi JB,

when I try to use the generic data source, I get the following exception
from blueprint:

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
find a matching constructor on class
org.apache.commons.pool.impl.GenericObjectPool for arguments [null, 8,
WHEN_EXHAUSTED_BLOCK, -1, 8, 2, false, false, -1, 3, 5000, false, -1, true]
when instanciating bean connectionPool

The data source is installed as bundle. We use Commons DBCP 1.4 and Commons
Pool 1.6. According to the javadoc, there should be a constructor with this
arguments:
http://commons.apache.org/proper/commons-pool/api-1.6/org/apache/commons/pool/impl/GenericObjectPool.html

Regards
Jochen



--
View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692p4035705.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Pooling with PostgreSQL and Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Jochen,

you now have the jdbc:* commands to create datasource. Especially the 
generic datasource use jdbc:

https://git-wip-us.apache.org/repos/asf?p=karaf.git;a=blob_plain;f=jdbc/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml;hb=HEAD

Regards
JB

On 10/08/2014 08:12 AM, jkraushaar wrote:
> Hi there,
>
> I like to set up a PostgreSQL data source in Karaf. In the Karaf-Tutorial a
> org.postgresql.ds.PGPoolingDataSource is used (see
> https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-postgres.xml).
> On the other hand PostgreSQL recommends to not use the pooled data source
> provided by them. Instead they refer to Apache Commons DBCP (see
> http://jdbc.postgresql.org/documentation/93/ds-ds.html). Also our custom
> Karaf assembly already has Commons DBCP 1.4 installed.
>
> What is your experience in the past? Is it save to use PGPoolingDataSource
> or should we use DBCP to create a connection pool instead?
>
> Regards
> Jochen
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Pooling-with-PostgreSQL-and-Karaf-tp4035692.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com