Hello.

I've tried to separate my feature in two features, with a prerequisite
for the configuration file, but I have still an issue.

The generated feature is :
<features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0";
name="my-test-26-karaf-2-routes">
    <feature name="my-test-26-karaf-2-routes-cfg" version="0.0.1.SNAPSHOT">
        <configfile
finalname="/etc/my_test_26_karaf_2_routes.cfg">mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT/cfg/configuration</configfile>
    </feature>
    <feature name="my-test-26-karaf-2-routes" description="karaf-test
:: Camel" version="0.0.1.SNAPSHOT">
        <details>karaf-test :: Camel routes</details>
        <feature version="2.25.4">camel-csv</feature>
        <feature version="2.25.4">camel-groovy</feature>
        <feature version="0.0.1-SNAPSHOT"
prerequisite="true">my-test-26-karaf-2-routes-cfg</feature>
        <bundle>mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT</bundle>
        <bundle>mvn:my.tests/my-test-26-karaf-1-api/0.0.1-SNAPSHOT</bundle>
    </feature>
</features>

When I install my-test-26-karaf-2-routes, my camel routes fail because
the configuration file is not deployed yet.

I've tried with option "-t" to see the simulation, and I have a
strange message about some loop :
"Error executing command: Deployment aborted due to loop in missing
prerequisites: [my-test-26-karaf-2-routes-cfg/0.0.1-SNAPSHOT]"

What's wrong with that ?

I agree that generally bundles should work when their configuration
changes, reloading them.
But in my case, camel endpoints need an first initial external
configuration to be set before starting : "<from
uri="file://{{my.input-folder}}" />" won't work if "my.input-folder"
is not resolved...

Thanks for your help.

Regards.

Le mar. 9 août 2022 à 18:31, Jean-Baptiste Onofré <[email protected]> a écrit :
>
> Hi,
>
> It's not a bug for two reasons:
>
> 1. If you absolutely need the config first, you can define a feature
> with the configuration and use prerequisite=true
> 2. Generally speaking a bundle should be able to deal with
> configuration update (basically a ManagedService instead of retrieving
> config service directly)
>
> Regards
> JB
>
> On Tue, Aug 9, 2022 at 3:54 PM Ephemeris Lappis
> <[email protected]> wrote:
> >
> > Hello.
> >
> > It seems that bundles that come from an installed feature are started
> > before the configuration file is installed.y
> >
> > My feature example XML :
> > <features xmlns="http://karaf.apache.org/xmlns/features/v1.6.0";
> > name="my-test-26-karaf-2-routes">
> >     <feature name="my-test-26-karaf-2-routes" description="karaf-test
> > :: Camel" version="0.0.1.SNAPSHOT">
> >         <details>karaf-test :: Camel routes</details>
> >         <configfile
> > finalname="/etc/my_test_26_karaf_2_routes.cfg">mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT/cfg/configuration</configfile>
> >         <feature version="2.25.4">camel-csv</feature>
> >         
> > <bundle>mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT</bundle>
> >         <bundle>mvn:my.tests/my-test-26-karaf-1-api/0.0.1-SNAPSHOT</bundle>
> >     </feature>
> > </features>
> >
> > When I install the feature using : repo-add -i
> > mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT/XML/features
> >
> > My camel bundle fails because it starts before the configuration file
> > is not installed yet. See the logs :
> > 2022-08-09T15:47:08,903 | INFO  | pipe-repo-add -i
> > mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT/XML/features |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Adding features:
> > my-test-26-karaf-2-routes/[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]
> > 2022-08-09T15:47:09,005 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Changes to perform:
> > 2022-08-09T15:47:09,005 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   Region: root
> > 2022-08-09T15:47:09,007 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |     Bundles to install:
> > 2022-08-09T15:47:09,010 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |       mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT
> > 2022-08-09T15:47:09,010 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |       mvn:org.apache.camel/camel-csv/2.25.4
> > 2022-08-09T15:47:09,010 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |       mvn:org.apache.commons/commons-csv/1.6
> > 2022-08-09T15:47:09,012 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Installing bundles:
> > 2022-08-09T15:47:09,013 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   mvn:my.tests/my-test-26-karaf-2-routes/0.0.1-SNAPSHOT
> > 2022-08-09T15:47:09,023 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   mvn:org.apache.camel/camel-csv/2.25.4
> > 2022-08-09T15:47:09,136 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   mvn:org.apache.commons/commons-csv/1.6
> > 2022-08-09T15:47:09,249 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Creating configuration file
> > C:\_F_\Programs\Java\Apache\apache-karaf-4.4.1\/etc/my_test_26_karaf_2_routes.cfg
> > 2022-08-09T15:47:09,263 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Starting bundles:
> > 2022-08-09T15:47:09,264 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   org.apache.commons.csv/1.6.0
> > 2022-08-09T15:47:09,267 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   org.apache.camel.camel-csv/2.25.4
> > 2022-08-09T15:47:09,271 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 |   my-test-26-karaf-2-routes/0.0.1.SNAPSHOT
> > 2022-08-09T15:47:09,310 | WARN  | features-3-thread-1 | BeanRecipe
> >                   | 89 - org.apache.aries.blueprint.core - 1.10.3 |
> > Object to be destroyed is not an instance of UnwrapperedBeanHolder,
> > type: null
> > 2022-08-09T15:47:09,312 | ERROR | features-3-thread-1 |
> > BlueprintContainerImpl           | 89 -
> > org.apache.aries.blueprint.core - 1.10.3 | Unable to start container
> > for blueprint bundle my-test-26-karaf-2-routes/0.0.1.SNAPSHOT
> > org.osgi.service.blueprint.container.ComponentDefinitionException:
> > Unable to initialize bean .camelBlueprint.factory.K1-Test
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:593)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:703)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:666)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:81)
> > ~[?:?]
> > at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_242]
> > at 
> > org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:90)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:360)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:338)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:152)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:809)
> > ~[?:?]
> > at 
> > org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:1014)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:573)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:417)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:335)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:288)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:284)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:274)
> > ~[?:?]
> > 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:1384)
> > ~[?:?]
> > at 
> > org.apache.felix.framework.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:730)
> > ~[?:?]
> > at 
> > org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:485)
> > ~[?:?]
> > at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4847) ~[?:?]
> > at org.apache.felix.framework.Felix.startBundle(Felix.java:2363) ~[?:?]
> > at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006) ~[?:?]
> > at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:992) ~[?:?]
> > at 
> > org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:165)
> > ~[?:?]
> > at 
> > org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1160)
> > ~[?:?]
> > at 
> > org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1041)
> > ~[?:?]
> > at 
> > org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)
> > ~[?:?]
> > at 
> > org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)
> > ~[?:?]
> > at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_242]
> > at 
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> > ~[?:1.8.0_242]
> > at 
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> > ~[?:1.8.0_242]
> > at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_242]
> > Caused by: org.apache.camel.RuntimeCamelException:
> > java.lang.IllegalArgumentException: Property with key
> > [my.input-folder] not found in properties from text:
> > file://{{my.input-folder}}
> > at 
> > org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1826)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:457)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:373)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:345)
> > ~[?:?]
> > at 
> > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.prepareRoutes(AbstractCamelContextFactoryBean.java:508)
> > ~[?:?]
> > at 
> > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:482)
> > ~[?:?]
> > at 
> > org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:355)
> > ~[?:?]
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> > ~[?:1.8.0_242]
> > at 
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> > ~[?:1.8.0_242]
> > at 
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > ~[?:1.8.0_242]
> > at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
> > at 
> > org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:337)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:835)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:591)
> > ~[?:?]
> > ... 38 more
> > Caused by: java.lang.IllegalArgumentException: Property with key
> > [my.input-folder] not found in properties from text:
> > file://{{my.input-folder}}
> > at 
> > org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:235)
> > ~[?:?]
> > at 
> > org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178)
> > ~[?:?]
> > at 
> > org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2546)
> > ~[?:?]
> > at 
> > org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:737)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.initRouteInputs(RouteDefinitionHelper.java:455)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.prepareRouteImp(RouteDefinitionHelper.java:373)
> > ~[?:?]
> > at 
> > org.apache.camel.model.RouteDefinitionHelper.prepareRoute(RouteDefinitionHelper.java:345)
> > ~[?:?]
> > at 
> > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.prepareRoutes(AbstractCamelContextFactoryBean.java:508)
> > ~[?:?]
> > at 
> > org.apache.camel.core.xml.AbstractCamelContextFactoryBean.setupRoutes(AbstractCamelContextFactoryBean.java:482)
> > ~[?:?]
> > at 
> > org.apache.camel.blueprint.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:355)
> > ~[?:?]
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> > ~[?:1.8.0_242]
> > at 
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> > ~[?:1.8.0_242]
> > at 
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > ~[?:1.8.0_242]
> > at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
> > at 
> > org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:337)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:835)
> > ~[?:?]
> > at 
> > org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:591)
> > ~[?:?]
> > ... 38 more
> > 2022-08-09T15:47:09,351 | INFO  | features-3-thread-1 |
> > FeaturesServiceImpl              | 18 - org.apache.karaf.features.core
> > - 4.4.1 | Done.
> > 2022-08-09T15:47:10,744 | INFO  |
> > fileinstall-C:\_F_\Programs\Java\Apache\apache-karaf-4.4.1\etc |
> > fileinstall                      | 17 - org.apache.felix.fileinstall -
> > 3.7.4 | Creating configuration {my_test_26_karaf_2_routes} from
> > C:\_F_\Programs\Java\Apache\apache-karaf-4.4.1\etc\my_test_26_karaf_2_routes.cfg
> >
> > Is it a bug ?
> > If this is not a bug, how can we set the configuration file such a way
> > it's installed before the bundles start ?
> >
> > Thanks for your help.
> >
> > Regards.

Reply via email to