-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Hi,
I'm new to pax-jdbc and karaf and I'm working on an evolution a route that has to use two different datasources (one postgresql and one oracle).
I'm facing an issue with Karaf (version 4.2.11) and creating jdbc datasources. I first created a DataSource pool connection for PostgreSQL and everything went fine I used this configuration file :
# configuration for pax-jdbc-config to choose and configure specific org.osgi.service.jdbc.DataSourceFactory
dataSourceName = <ds_name>
dataSourceType = DataSource
osgi.jdbc.driver.class = org.postgresql.Driver
url = jdbc:postgresql://<host>/<db_name>
user = <username>
password = <password>
# hints for pax-jdbc-config to use org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory
pool = dbcp2
xa = false
# dbcp2 specific configuration of org.apache.commons.pool2.impl.GenericObjectPoolConfig
pool.minIdle = 2
pool.maxTotal = 50
pool.blockWhenExhausted = true
pool.maxWaitMillis = 2000
pool.testOnBorrow = true
pool.testWhileIdle = false
# dbcp2 specific configuration of org.apache.commons.dbcp2.PoolableConnectionFactory
factory.validationQuery = select schema_name from information_schema.schemata
factory.validationQueryTimeout = 2
And I tried to create another one for Oracle using the same template :
# configuration for pax-jdbc-config to choose and configure specific org.osgi.service.jdbc.DataSourceFactory
dataSourceName = <ds_name>
dataSourceType = DataSource
osgi.jdbc.driver.class = oracle.jdbc.OracleDriver
url = jdbc:oracle:thin:@//<host>:<port>/<service_name>
user = <username>
password = <password>
# hints for pax-jdbc-config to use org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory
pool = dbcp2
xa = false
# dbcp2 specific configuration of org.apache.commons.pool2.impl.GenericObjectPoolConfig
pool.minIdle = 2
pool.maxTotal = 50
pool.blockWhenExhausted = true
pool.maxWaitMillis = 2000
pool.testOnBorrow = true
pool.testWhileIdle = false
# dbcp2 specific configuration of org.apache.commons.dbcp2.PoolableConnectionFactory
factory.validationQuery = SELECT TRUNC(CURRENT_DATE) AS current_date FROM dual
factory.validationQueryTimeout = 2
But after I put the file in the container it creates duplicates of the object :
The drivers versions are :
Postgresql : 42.2.2
Oracle : ojdbc8/19.13.0.0.1
And the features installed on karaf :
jdbc : 4.2.11
pax-jdbc-pool-dbcp2 : 1.4.4
jndi : 4.2.11
logs when putting the cfg file in the etc folder :
2025-01-08T16:54:56,305 | INFO | fileinstall-C:\Talend\TOS_ESB-20211109_1610-V8.0.1\Runtime_ESBSE\container\etc | install.internal.Util$OsgiLogger 205 | 12 - org.apache.felix.fileinstall - 3.6.8 | Creating configuration from org.ops4j.datasource-urtest.cfg
2025-01-08T16:54:56,309 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory)(pool=dbcp2)(xa=false))
2025-01-08T16:54:56,310 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,310 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,315 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,315 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,316 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,316 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,317 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,317 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,319 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,319 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,320 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,320 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,322 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,322 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
2025-01-08T16:54:56,323 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.ServiceTrackerHelper$1 132 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.class=oracle.jdbc.OracleDriver))
2025-01-08T16:54:56,323 | INFO | CM Configuration Updater (Update: pid=org.ops4j.datasource.1a582fed-c02e-493f-b1ee-443d8bcbd68a) | nfig.impl.DataSourceRegistration 82 | 406 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource urtest
(the logs are cropped, there are like 800 lines that are repeated)
After the command ls org.osgi.service.jdbc.DataSourceFactory
I had like 300 objects all with the osgi.jdbc.driver.class = oracle.jdbc.OracleDriver and each one had a different osgi.jdbc.driver.name like org.apache.servicemix.bundles.jasypt-spring31-native and org.apache.karaf.jaas.jasypt-native
Is there something missing on my configuration file specific for Oracle db or something on my karaf installation that might cause this issue ?
Thanks
stackoverflow post : https://stackoverflow.com/questions/79338900/karaf-multiple-dbcp2-datasource-created-when-creating-a-datasource
output of ls org.osgi.service.jdbc.DataSourceFactory
:
ls_org_osgi_service_jdbc_DataSourceFactory_output.txt
output of ls javax.sql.DataSource
(I removed sensistive elements password and urls) :
ls_javax_sql_DataSource_output.txt