ops4j / org.ops4j.pax.jdbc

An OSGi JDBC Service Implementation, including adapters for various database drivers
Apache License 2.0
44 stars 68 forks source link

Aries JDBC managed DataSource gets wrapped again [PAXJDBC-49] #127

Closed grgrzybek closed 7 years ago

grgrzybek commented 10 years ago

Benjamin Graf created PAXJDBC-49

If you configure a DataSource via pax-jdbc-config and pax-jdbc-pool-aries the exported DataSource service gets wrapped again by aries jdbc itself. IMHO it because pax-jdbc-config does not export aries.managed flag to show aries jdbc that it is already managed.


Affects: 0.4.0 Fixed in: 1.0.1 Attachments:

Votes: 1, Watches: 6

grgrzybek commented 9 years ago

Benjamin Graf commented

Commit patch to allow key "aries.managed=true". This should avoid that DataSource service gets wrapped for aries pool again.

grgrzybek commented 9 years ago

Christian Schneider commented

pax-jdbc-pool-dbcp2 only creates a DataSourceFactory not a DataSource. I thought the same would apply for pax-jdbc-pool-aries.

Can you explain in more detail how to reproduce and what the error is?

grgrzybek commented 8 years ago

Jörn Gersdorf commented

I hit the same issue using pax-jdbc-pool-aries/0.8 on Karaf 2.4. Description:

I have installed pax-jdbc, pax-jdbc-config, pax-jdbc-oracle and pax-jdbc-pool-aries, all version 0.8.0.

I have following configuration file:

$ cat org.ops4j.datasource-oracle-local.cfg
osgi.jdbc.driver.class=oracle.jdbc.OracleDriver-pool
dataSourceName=mydatasource
url=${someurl}
user=${someuser}
password=${somepassword}

This leads to following two OSGi DataSources installed in Karaf, one created by pax-jdbc-config and one created by aries-transaction-jdbc/2.1.0, see below.

As pax-jdbc-pool-aries itself is already wrapping the Datasource for pooling/XA: how can I avoid that aries-transaction-jdbc/2.1.0 is doing this on top? Or is this expected behaviour?

Thanks!

admin@root> bundle-services -p 100

org.ops4j.pax.jdbc.config provides:
----------------------------------
objectClass = [org.osgi.service.cm.ManagedServiceFactory]
service.id = 275
service.pid = org.ops4j.datasource
----
dataSourceName = mydatasource
felix.fileinstall.filename = file:/B:/minimal-distro-6.2.1.redhat-084/etc/org.ops4j.datasource-oracle-local.cfg
objectClass = [javax.sql.DataSource]
osgi.jdbc.driver.class = oracle.jdbc.OracleDriver-pool
osgi.jndi.service.name = mydatasource
password = ${somepassword}
service.factoryPid = org.ops4j.datasource
service.id = 310
service.pid = org.ops4j.datasource.ef3848dd-125f-49d8-bcb0-868ddb2b214f
url = ${someurl}
user = ${someuser}
----
aries.managed = true
dataSourceName = mydatasource
felix.fileinstall.filename = file:/B:/minimal-distro-6.2.1.redhat-084/etc/org.ops4j.datasource-oracle-local.cfg
objectClass = [javax.sql.DataSource]
osgi.jdbc.driver.class = oracle.jdbc.OracleDriver-pool
osgi.jndi.service.name = mydatasource
password = ${somepassword}
service.factoryPid = org.ops4j.datasource
service.id = 311
service.pid = org.ops4j.datasource.ef3848dd-125f-49d8-bcb0-868ddb2b214f
service.ranking = 1000
url = ${someurl}
user = ${someuser}

aries-transaction-jdbc/2.1.0 is pulled in by the pax-jdbc-pool-aries feature itself:

admin@root> features:info pax-jdbc-pool-aries
Description of pax-jdbc-pool-aries 0.8.0 feature
 Provides JDBC Pooling DataSourceFactory using Aries Transaction JDBC
----------------------------------------------------------------
Feature has no configuration
Feature has no configuration files
Feature depends on:
  pax-jdbc-spec 0.0.0
Feature contains followed bundles:
 mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
 mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.6_spec/1.0
 mvn:org.apache.geronimo.specs/geronimo-validation_1.0_spec/1.1
 mvn:org.apache.geronimo.components/geronimo-connector/3.1.1
 mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/1.1.0
 mvn:org.apache.aries.transaction/org.apache.aries.transaction.jdbc/2.1.0
 mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/0.8.0
 mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-aries/0.8.0
Feature has no conditionals.
grgrzybek commented 8 years ago

Benjamin Graf commented

Add following entries as workaround for pax-jdbc-config:
aries.managed=true
aries.xa.aware=true (if xa !)

grgrzybek commented 7 years ago

Christian Schneider commented

I can reproduce the issue in pax-jdbc 1.0.0 in karaf 4.1.0:

feature:repo-add pax-jdbc.1.0.0
feature:install pax-jdbc-h2 pax-jdbc-config pax-jdbc-pool-aries

Add the config attached to the issue.

There will be two DataSource services one from pax-jdbc and one from aries pooling directly.

grgrzybek commented 7 years ago

Christian Schneider commented

I embedded aries transaction jdbc now to avoid that it needs to be installed as a bundle. Can you validate that this fixes the problem?

We will also add a config in aries transaction to avoid the auto wrapping.

grgrzybek commented 7 years ago

Benjamin Graf commented

Do you really think embedding is a good solution? What about just export those two properties mentioned before? This makes upgrading aries transaction jdbc quite difficult!