Setup database structure before bundle under test is started with pax exam + karaf

219 views
Skip to first unread message

karste...@hermes-ottoint.com

unread,
Aug 24, 2017, 3:36:05 AM8/24/17
to OPS4J
Hello everybody,
i am running pax exam 4 with a karaf 3 container.
The bundle under test is a camel 2.16.3 bundle.
The bundle uses a time triggered camel jpa component and pax-jdbc with (XA and pooling) to instantiate the datasource.
For the test i need some table and some test data in a schema.
If i run the test with an existing postgres database everything is fine. If i try to instantiate and setup the database first (H2 or Derby) the bundle under test does not
find the database with the jndi name:
javax.naming.NameNotFoundException: osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/scv_xa)"

How can i startup and setup the temporary db before the bundle under test is started?

Thanks and best regards
Karsten

laeubi...@googlemail.com

unread,
Aug 29, 2017, 9:36:32 AM8/29/17
to OPS4J
You should provide a little more info about your setup, e.g. "working" vs "not working" configs, how you run the camel bundle (bluprint? spring? Routebuilders?)

I assume you want to test the route itself not the pax-jdbc setup, then you should configure your datasource that way that it can either run from JNDI or or a local jdbc-url to make testing easier.
You can the provide a config for test and one for deployment that contains either jndi or plain jdbc with e.g. inmemory db of h2 (which can be configured to init the db from a file).

Blume, Karsten

unread,
Aug 30, 2017, 3:30:33 AM8/30/17
to op...@googlegroups.com

Hello,

yes this might help.

Bundle under test is a blueprint bundle with a camel jpa endpoint/component

       <bean

              id="jpa"

              class="org.apache.camel.component.jpa.JpaComponent">

              <jpa:unit

                     unitname="shipment"

                     property="entityManagerFactory" />

              <property

                     name="transactionManager"

                     ref="transactionManager" />

       </bean>

 

and a persistence.xml

       <persistence-unit

              name="shipment"

              transaction-type="JTA">

              <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/scv_xa)</jta-data-source>

 

a running live pax-jdbc configuration

this works also for the pax exam test

osgi.jdbc.driver.name = PostgreSQL JDBC Driver-pool-xa

databaseName=scv

dataSourceName=jdbc/scv_xa

user=xxx

password=xxx

url = jdbc:postgresql:// 155:155:155:155:5432/scv

 

What does not work:

A pax exam pax-jdbc configuration which I expect starts up the db before starting the test like:

osgi.jdbc.driver.name=derby-pool-xa

databaseName=scv

dataSourceName=jdbc/scv_xa

user=xxx

password=xxx

url=jdbc:derby:target/scvdev;create=true;user=xxx;password=xxx

or similar with H2

 

For the different test methods I need different test data inserted into the db. So a single startup script is not sufficient.

 

For the pax exam tests

How can a startup the db, modify it per test method and publish it so that the probe and the bundle under test can access it?

 

Regards

Karsten

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to a topic in the Google Groups "OPS4J" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ops4j/F1YhX1Fvq_Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ops4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christoph Läubrich

unread,
Aug 30, 2017, 4:36:52 AM8/30/17
to op...@googlegroups.com

Can you explain what error do you get? Database not found? are the tables not created?

How is your test triggered? By timer?


Can you create a simpler test-case you can publish on github that shows your problem?

You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

karste...@hermes-ottoint.com

unread,
Aug 30, 2017, 5:46:26 AM8/30/17
to OPS4J
full Stack Trace for exception and log excerpt
datasources.osgi includes the pax-jdbc config files in live, for test the additional pax-jdbc bundles for derby and config files are added in the PaxExam configure() method
The only strange thing i see now is that the "Creating DataSource" log message is after the JNDI search by "org.apache.aries.jpa.container".
Might this be the cause? And how to change?

...
2017-08-30 11:26:42,770 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature datasources.osgi 17.32.2-SNAPSHOT | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:42,770 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature camel-jdbc 2.16.3 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:42,772 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-config 0.9.0 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:42,772 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-spec 0.9.0 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:42,776 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-postgresql 0.9.0 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:42,777 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-pool-dbcp2 0.9.0 | bcid:                      exchange:                      msgid:                    

....

2017-08-30 11:26:44,968 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-derby 0.9.0 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:26:44,968 | INFO  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-spec 0.9.0 | bcid:                      exchange:                      msgid:                    
....
2017-08-30 11:27:04,677 | INFO  | Factory Update: factoryPid=[org.ops4j.datasource]) | nfig.impl.DataSourceRegistration | Detected config for DataSource jdbc/scv. Tracking DSF with filter (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=derby-pool)) | bcid:                      exchange:                      msgid:                    
2017-08-30 11:27:05,343 | INFO  | Factory Update: factoryPid=[org.ops4j.datasource]) | nfig.impl.DataSourceRegistration | Detected config for DataSource jdbc/scv_xa. Tracking DSF with filter (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=derby-pool-xa)) | bcid:                      exchange:                      msgid:                    
...

2017-08-30 11:27:27,421 | INFO  | FelixStartLevel                                    | openjpa.Runtime                  | Starting OpenJPA 2.2.2 | bcid:                      exchange:                      msgid:                    
2017-08-30 11:27:27,482 | ERROR | FelixStartLevel                                    | org.apache.aries.jpa.container   | The DataSource osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/scv_xa) required by bundle UNDERTEST/17.32.2.SNAPSHOT could not be found. | bcid:                      exchange:                      msgid:                    
javax.naming.NameNotFoundException: osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/scv_xa)"
    at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:113)
    at org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:138)
    at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:66)
    at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
    at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:110)
    at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:87)
    at org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:91)
    at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:603)
    at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1518)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:531)
    at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:456)
    at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:120)
    at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
    at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:967)
    at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:958)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:644)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.aries.jpa.container.impl.QuiesceEMFHandler.invoke(QuiesceEMFHandler.java:57)
    at com.sun.proxy.$Proxy20.createEntityManager(Unknown Source)
    at Proxy427db9a9_7d82_4c6b_813a_8f985fdc14d1.createEntityManager(Unknown Source)
    at org.apache.camel.component.jpa.JpaConsumer.doStart(JpaConsumer.java:518)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3234)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3528)
    at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3464)
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3394)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3162)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3018)
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2814)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2810)
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2833)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2810)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2779)
    at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)
    at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)
    at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)
    at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:932)
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:793)
    at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543)
    at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4419)
    at org.apache.felix.framework.Felix.registerService(Felix.java:3423)
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:352)
    at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:980)
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:736)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:848)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:255)
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:186)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:724)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:411)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)
    at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
    at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
    at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:516)
    at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(FeaturesServiceImpl.java:474)
    at org.apache.karaf.features.internal.BootFeaturesInstaller.installBootFeatures(BootFeaturesInstaller.java:92)
    at org.apache.karaf.features.internal.BootFeaturesInstaller.start(BootFeaturesInstaller.java:76)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:980)
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:736)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:848)
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
    at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:255)
    at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:186)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:724)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:411)
    at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:276)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:300)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:269)
    at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:265)
    at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:255)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
    at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
    at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)
    at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2092)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
    at java.lang.Thread.run(Thread.java:745)

...

2017-08-30 11:28:00,485 | INFO  | FelixStartLevel                                    | nfig.impl.DataSourceRegistration | Creating DataSource jdbc/scv | bcid:                      exchange:                      msgid:                    
2017-08-30 11:28:00,505 | INFO  | FelixStartLevel                                    | nfig.impl.DataSourceRegistration | Creating DataSource jdbc/scv_xa | bcid:                      exchange:                      msgid:                    


karste...@hermes-ottoint.com

unread,
Aug 30, 2017, 5:49:19 AM8/30/17
to OPS4J
How is your test triggered? By timer?

The test is started automatically by PaxExam.


Can you create a simpler test-case you can publish on github that shows your problem?


Not really, because there are several additional dependencies (db unrelated) involved.

Christoph Läubrich

unread,
Aug 30, 2017, 12:39:02 PM8/30/17
to op...@googlegroups.com
From the log it seems your blueprint starts up before the service is registered. Since Camel does not know directly about the dependency you might try the following:
Let your blueprint import a javax.sql.DataSource service, then it won't start up before one is avaiable e.g. with

  <reference id="wait-for-service" interface="javax.sql.DataSource" />
that will make your bundle wait for at least one DatasourceService (you might want to adjust the interface if pax-jdbc registers a different one, havent checked that...).

Beside that you should check if camel can even use those fetched service as a datasource instead of JNDI because that might create issues if the service changes while blueprint keeps track of those changes.

karste...@hermes-ottoint.com

unread,
Aug 31, 2017, 12:01:07 PM8/31/17
to OPS4J
I have added to the blueprint description of my bundle under test:

    <reference id="wait-for-service-scv" interface="javax.sql.DataSource"
        filter="(osgi.jndi.service.name=jdbc/scv)" />

with no result.
Getting still the unfriendly Exception and after that the
INFO  | FelixStartLevel               
                     | nfig.impl.DataSourceRegistration | Creating DataSource jdbc/scv

message.

what do you mean by :
-- "
Beside that you should check if camel can even use those fetched service as a datasource instead of JNDI because that might create issues if the service changes while blueprint keeps track of those changes."?

karste...@hermes-ottoint.com

unread,
Sep 1, 2017, 2:55:16 AM9/1/17
to OPS4J
here is some more information:
i have started the karaf service created by pax exam manually, getting on the command line:

service:list DataSource shows:

[javax.sql.DataSource]
----------------------
 databaseName = scvdev
 dataSourceName = jdbc/scv_xa
 felix.fileinstall.filename = file:/D:/HYPER-V/data/git/AMX/hoi.itest.karaf/target/pax/fe9a14e5-ac9a-47a3-acb8-bec13851ab36/etc/org.ops4j.datasource-scv_xa.cfg
 osgi.jdbc.driver.name = derby-pool-xa
 osgi.jndi.service.name = jdbc/scv_xa
 password = xxx
 service.factoryPid = org.ops4j.datasource
 service.id = 409
 service.pid = org.ops4j.datasource.5d401396-0dc7-445e-8dad-0c1077a2a28f
 url = jdbc:derby:target/scvdev;create=true;user=xxx;password=xxx
 user = xxx
Provided by :
 OPS4J Pax JDBC Config (39)

also
jdbc:datasources shows:
jdbc/scv_xa, 409           | Apache Derby | 10.11.1.1 - (1616546) | jdbc:derby:target/scvdev                                                                                                                                                                                            | OK
and jdbc:tables shows all the Derby system tables.

So this seems to be a timing problem between those bundles.
Wondering does nobody use the pax-jdbc bundle and pax exam?

Christoph Läubrich

unread,
Sep 1, 2017, 3:53:26 AM9/1/17
to op...@googlegroups.com
Hi,

I mean that you already have the datasource at hand so there is no need
to look it up in JNDI. But it seems there is no way of connecting camel
with the underlying persitence unit.

BTW: Your problem has nothing to do with pax-jdbc or pax-exam it is more
related to aries-jpa that does not account the dynamic nature of OSGi
when doing the JNDI lookup it obviously does not wait for a service to
become available but fails instantly.

What you can try is to adjust the start order of your bundles so the
pax-jdbc, config-admin and derby bundles start as soon as possible
before aries-jpa kicks in. Also make yure your osgi-jndi bundle starts
as soon as possible!
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google
> Groups "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ops4j+un...@googlegroups.com
> <mailto:ops4j+un...@googlegroups.com>.

Christian Schneider

unread,
Sep 11, 2017, 3:55:54 AM9/11/17
to op...@googlegroups.com
You can use the new PreHook of pax-jdbc.
It allows to run an OSGi service before the datasource is published.

This can be used in production and test for db migration as well as for setup of a temp db before each test.

This is an example for a migration hook:
https://github.com/cschneider/Karaf-Tutorial/blob/master/liquibase/service/src/main/java/net/lr/tutorial/db/service/Migrator.java

and this is how to use it in the config:
https://github.com/cschneider/Karaf-Tutorial/blob/master/liquibase/org.ops4j.datasource-person.cfg

Christian
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


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

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

karste...@hermes-ottoint.com

unread,
Sep 12, 2017, 5:45:11 AM9/12/17
to OPS4J
Hello Christian,
the PreHook is in pax-jdbc 1.2.0 but i cannot run this in Karaf 3.0.7, the namespace of the features.xml is unknown.
2017-09-12 10:17:06,820 | WARN  | FelixStartLevel                                    | res.internal.FeaturesServiceImpl | Unable to add features repository mvn:org.ops4j.pax.jdbc/pax-jdbc-features/1.2.0/xml/features at startup | bcid:
                exchange:                      msgid:
java.lang.IllegalArgumentException: Unrecognized root element: {http://karaf.apache.org/xmlns/features/v1.4.0}features
        at org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
        at org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
        at org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)

Reply all
Reply to author
Forward
0 new messages