The available properties depend on the DataSourceFactory.

See this doc for the options you can use:
https://ops4j1.jira.com/wiki/display/PAXJDBC/Apache+Derby+Driver+Adapter

Christian

On 08.07.2016 16:39, Bengt Rodehav wrote:
Unfortunately I spoke to soon...

Using pax-jdbc a DataSource service is created but it isn't picked by Blueprint JPA. It was the one I created with my Blueprint that was used. I have:

/karaf@root()> service:list DataSource/
/[javax.sql.DataSource]/
/----------------------/
/ dataSourceName = filetransferhistory/
/ felix.fileinstall.filename = file:/C:/dev/karaf/connect/head/apache-karaf-4.0.5/etc/org.ops4j.datasource-filetransferhistory.cfg/
/osgi.jdbc.driver.name <http://osgi.jdbc.driver.name> = derby-pool-xa/
/osgi.jndi.service.name <http://osgi.jndi.service.name> = filetransferhistory/
/ service.bundleid = 162/
/ service.factoryPid = org.ops4j.datasource/
/service.id <http://service.id> = 338/
/ service.pid = org.ops4j.datasource.c55c28be-f6f8-4e00-8448-92dfa20bedb5/
/ service.scope = singleton/
/ url = jdbc:derby:historyDB;createDatabase=create/
/Provided by :/
/ OPS4J Pax JDBC Config (162)/
/
/
/[javax.sql.DataSource]
/
/----------------------/
/osgi.jndi.service.name <http://osgi.jndi.service.name> = jdbc/filetransferhistory/
/ osgi.service.blueprint.compname = derbyDataSource/
/ service.bundleid = 204/
/service.id <http://service.id> = 358/
/ service.scope = bundle/
/Provided by :/
/ Connect :: filetransfer-history-datasource (204)/
/Used by:/
/ Apache Aries JPA container (38)/

It's the last one above that is being picked up and used to publish an EnityManager service. My blueprint looks like this:

/<?xml version="1.0" encoding="UTF-8"?>/
/<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/ /xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"; default-activation="lazy">/
/
/
/ <bean id="derbyDataSource" class="org.apache.derby.jdbc.EmbeddedDataSource">
/
/    <property name="databaseName" value="historyDB" />/
/    <property name="createDatabase" value="create" />/
/  </bean>/
/
/
/  <service ref="derbyDataSource" interface="javax.sql.DataSource">/
/<service-properties>/
/ <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name>" value="jdbc/filetransferhistory" />/
/</service-properties>/
/  </service>/
/
/
/</blueprint>/

It works but it is not an XA data source.

I don't understand what other difference there is between the service published by pax-jdbc(338) and the one published by blueprint(358).

I install the folllowing pax-jdbc features:

- pax-jdbc-derby
- pax-jdbc-pool-dbcp2
- pax-jdbc-config

I also have a configuration file called org.ops4j.datasource-filetransferhistory.cfg with content:

/osgi.jdbc.driver.name <http://osgi.jdbc.driver.name>=derby-pool-xa/
/url=jdbc:derby:historyDB;createDatabase=create/
/dataSourceName=filetransferhistory
/

I have the following data source factories:

/karaf@root()> service:list DataSourceFactory/
/[org.osgi.service.jdbc.DataSourceFactory]/
/-----------------------------------------/
/ osgi.jdbc.driver.class = org.apache.derby.jdbc.EmbeddedDriver/
/osgi.jdbc.driver.name <http://osgi.jdbc.driver.name> = derby/
/ service.bundleid = 163/
/service.id <http://service.id> = 331/
/ service.scope = singleton/
/Provided by :/
/ OPS4J Pax JDBC Apache Derby Driver Adapter (163)/
/Used by:/
/ OPS4J Pax JDBC Pooling Support using Commons-DBCP2 (165)/
/
/
/[org.osgi.service.jdbc.DataSourceFactory]/
/-----------------------------------------/
/ osgi.jdbc.driver.class = org.apache.derby.jdbc.EmbeddedDriver-pool/
/osgi.jdbc.driver.name <http://osgi.jdbc.driver.name> = derby-pool/
/ pooled = true/
/ service.bundleid = 165/
/service.id <http://service.id> = 336/
/ service.scope = singleton/
/Provided by :/
/ OPS4J Pax JDBC Pooling Support using Commons-DBCP2 (165)/
/
/
/[org.osgi.service.jdbc.DataSourceFactory]/
/-----------------------------------------/
/ osgi.jdbc.driver.class = org.apache.derby.jdbc.EmbeddedDriver-pool-xa/
/osgi.jdbc.driver.name <http://osgi.jdbc.driver.name> = derby-pool-xa/
/ pooled = true/
/ service.bundleid = 165/
/service.id <http://service.id> = 337/
/ service.scope = singleton/
/ xa = true/
/Provided by :/
/ OPS4J Pax JDBC Pooling Support using Commons-DBCP2 (165)/
/Used by:/
/ OPS4J Pax JDBC Config (162)/

Everything looks fine to me but I get no EntityManager created with the pax-jdbc data sources...

One thing I noticed is that in my Blueprint, I do not use the "url" property. Instead I set the two properties "databaseName" and "createDatabase". If I try to use the "url" property in my Blueprint I get the following error:

/2016-07-08 16:20:42,297 | ERROR | lixDispatchQueue | container | ? ? | FrameworkEvent ERROR - org.apache.aries.jpa.container/ /org.osgi.framework.ServiceException: Service factory exception: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find property descriptor url on class org.apache.derby.jdbc.EmbeddedDataSource/ /at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:352)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:247)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:344)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.Felix.getService(Felix.java:3699)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:470)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.aries.jpa.container.impl.DataSourceTracker.addingService(DataSourceTracker.java:85)[38:org.apache.aries.jpa.container:2.3.0]/ /at org.apache.aries.jpa.container.impl.DataSourceTracker.addingService(DataSourceTracker.java:37)[38:org.apache.aries.jpa.container:2.3.0]/ /at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]/ /at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]/ /at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]/ /at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]/ /at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]/ /at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.Felix.registerService(Felix.java:3549)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:492)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:193)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:746)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:413)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[46:org.apache.aries.util:1.1.1]/ /at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[46:org.apache.aries.util:1.1.1]/ /at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[46:org.apache.aries.util:1.1.1]/ /at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[46:org.apache.aries.util:1.1.1]/ /at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[46:org.apache.aries.util:1.1.1]/ /at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1179)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:731)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:486)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.4.0.jar:]/ /at org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)[73:org.apache.karaf.bundle.core:4.0.5]/ /at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:64)[73:org.apache.karaf.bundle.core:4.0.5]/ /at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)[73:org.apache.karaf.bundle.core:4.0.5]/ /at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[97:org.apache.karaf.shell.core:4.0.5]/ /at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:270)[97:org.apache.karaf.shell.core:4.0.5]/
/at java.lang.Thread.run(Thread.java:745)[:1.8.0_74]/
/Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find property descriptor url on class org.apache.derby.jdbc.EmbeddedDataSource/ /at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:310)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:252)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:365)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:541)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:347)[org.apache.felix.framework-5.4.0.jar:]/
/... 51 more/
/Caused by: org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to find property descriptor url on class org.apache.derby.jdbc.EmbeddedDataSource/ /at org.apache.aries.blueprint.container.BeanRecipe.getPropertyDescriptor(BeanRecipe.java:976)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:958)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:929)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:910)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:844)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[24:org.apache.aries.blueprint.core:1.6.1]/
/at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_74]/
/at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.di.RefRecipe.internalCreate(RefRecipe.java:62)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[24:org.apache.aries.blueprint.core:1.6.1]/ /at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:285)[24:org.apache.aries.blueprint.core:1.6.1]/
/... 55 more/

So, maybe the "url" property can't be used for pax-jdbc-derby?


/Bengt



--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to