Hello I checked your example and had to tweak it a bit to build your branch:
diff --git a/examples/karaf-docker-example/karaf-docker-example-startup-feature/pom.xml b/examples/karaf-docker-example/karaf-docker-example-startup-feature/pom.xml index def1e659979..a3c64c64d57 100644 --- a/examples/karaf-docker-example/karaf-docker-example-startup-feature/pom.xml +++ b/examples/karaf-docker-example/karaf-docker-example-startup-feature/pom.xml @@ -31,7 +31,7 @@ <artifactId>karaf-docker-example-startup-app-feature</artifactId> - <packaging>feature</packaging> + <packaging>pom</packaging> <description>my.company.feature details</description> @@ -68,6 +68,28 @@ <artifactId>maven-install-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>src/main/feature/feature.xml</file> + <classifier>features</classifier> + <type>xml</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> build-helper-maven-plugin is required to produce additional artifact and make it available to Maven reactor (and have it installed in ~/.m2/repository) Then I run the distro: $ cd examples/karaf-docker-example/karaf-docker-example-dynamic-dist/ $ cd target/assembly/ $ bin/karaf and installed `camel` feature: karaf@root()> repo-add mvn:org.apache.camel.karaf/apache-camel/3.22.2/xml/features Adding feature url mvn:org.apache.camel.karaf/apache-camel/3.22.2/xml/features karaf@root()> feature:install -v camel Adding features: camel/[3.22.2,3.22.2] Changes to perform: Region: root Bundles to install: mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.1 mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.cm/1.3.2 ... In logs I can see info like this: 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Adding features: camel/[3.22.2,3.22.2] 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Changes to perform: 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Region: root 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Bundles to install: 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.cm/1.3.2 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core/1.10.3 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.jmx/org.apache.aries.jmx.blueprint.api/1.2.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.jmx/org.apache.aries.jmx.blueprint.core/1.2.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.proxy/org.apache.aries.proxy/1.1.14 ... 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Installing bundles: 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.cm/1.3.2 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core/1.10.3 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.jmx/org.apache.aries.jmx.blueprint.api/1.2.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.jmx/org.apache.aries.jmx.blueprint.core/1.2.0 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.aries.proxy/org.apache.aries.proxy/1.1.14 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | mvn:org.apache.camel/camel-api/3.22.2 ... 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Starting bundles: 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | stax2-api/4.2.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | woodstox-core-asl/4.4.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | org.apache.servicemix.bundles.jaxb-runtime/2.3.1.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | org.apache.aries.blueprint.api/1.0.1 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | org.objectweb.asm/9.7.0 ... 137 - org.apache.camel.karaf.camel-core-osgi - 3.22.2 | Camel activator starting 137 - org.apache.camel.karaf.camel-core-osgi - 3.22.2 | Camel activator started ... 52 - org.apache.karaf.shell.core - 4.5.0.SNAPSHOT | Registering commands for bundle org.apache.camel.karaf.camel-karaf-commands/3.22.2 52 - org.apache.karaf.shell.core - 4.5.0.SNAPSHOT | Updating commands for bundle org.apache.karaf.shell.commands/4.5.0.SNAPSHOT 19 - org.apache.karaf.features.core - 4.5.0.SNAPSHOT | Done. If you see Pax Logging being refreshed, it means you (your feature) installs additional bundle(s) which (calculation done by FeaturesService) causes refresh of Pax Logging. I can't see it with the reproducer (your feature is empty), but please look for logs like "Refreshing bundles" and send it here. kind regards Grzegorz Grzybek wt., 21 maj 2024 o 19:28 Matthias Leinweber <m.leinwe...@datatactics.de> napisał(a): > Hi Grzegorz > > > https://github.com/lnnwvr/karaf/tree/startup-also-boot/examples/karaf-docker-example > > you can see the odd behaviour ,... > > featuresBoot = \ > instance/4.5.0.SNAPSHOT, \ > package/4.5.0.SNAPSHOT, \ > scr/4.5.0.SNAPSHOT, \ > log/4.5.0.SNAPSHOT, \ > karaf-docker-example-app/4.5.0.SNAPSHOT, \ > karaf-docker-example-startup-app-feature/4.5.0.SNAPSHOT, \ ##### > startUpFeature > ssh/4.5.0.SNAPSHOT, \ > pax-web-http-whiteboard/8.0.27, \ > framework/4.5.0.SNAPSHOT, \ #### Should not be here at all? > system/4.5.0.SNAPSHOT, \ > eventadmin/4.5.0.SNAPSHOT, \ #### startUpFeature > feature/4.5.0.SNAPSHOT, \ > shell/4.5.0.SNAPSHOT, \ > management/4.5.0.SNAPSHOT, \ > service/4.5.0.SNAPSHOT, \ > jaas/4.5.0.SNAPSHOT, \ > deployer/4.5.0.SNAPSHOT, \ > diagnostic/4.5.0.SNAPSHOT, \ > wrap/2.6.14, \ > bundle/4.5.0.SNAPSHOT, \ > config/4.5.0.SNAPSHOT, \ > kar/4.5.0.SNAPSHOT > > On Tue, 21 May 2024 at 18:25, Grzegorz Grzybek <gr.grzy...@gmail.com> > wrote: > >> >> >> wt., 21 maj 2024 o 15:47 Matthias Leinweber <m.leinwe...@datatactics.de> >> napisał(a): >> >>> Hi, >>> >>> this is at least an explanation for the refresh. But the bootFeatures >>> still seem bugg. Should i try to create a simple test with karaf examples? >>> >> >> If you provide some github example, I could review it ;) >> >> regards >> Grzegorz >> >> >>> >>> br, >>> Matthias >>> >>> On Tue, 21 May 2024 at 15:31, Grzegorz Grzybek <gr.grzy...@gmail.com> >>> wrote: >>> >>>> The logs should contain an explanation. >>>> >>>> pax-logging-log4j2 (or your fragment) may contain some optional >>>> (resolution:=optional) imports which are satisfied by some bundles from >>>> Camel features... This makes Karaf's FeatureService include Pax Logging in >>>> the set of "bundles to refresh". >>>> The details should be in the logs. >>>> >>>> regards >>>> Grzegorz >>>> >>>> wt., 21 maj 2024 o 15:25 Matthias Leinweber <m.leinwe...@datatactics.de> >>>> napisał(a): >>>> >>>>> Hi, >>>>> >>>>> >>>>> >> compile scopeby default goes to "startup" phase of "profile >>>>> management". >>>>> Ah ok this is working now too.. >>>>> >>>>> Then it is also added to the boot features. >>>>>> >>>>>> >>>>>> Hmm, I'm not sure why's that... Even if it's true (I can't check >>>>>> now), it shouldn't affect the process and cause extra refreshes. >>>>>> In extreme case, where all the features are "startup", you should get >>>>>> all the bundles installed (and active if not fragments) the moment >>>>>> Karaf's >>>>>> FeatureService kicks in... >>>>>> >>>>> >>>>> The thing is when i install e.g. feature camel, pax-logging gets >>>>> restarted for idk why. If i remove rahla.logging from >>>>> >>>>> featuresBoot = \ >>>>> instance/4.4.6, \ >>>>> package/4.4.6, \ >>>>> log/4.4.6, \ >>>>> rahla.logging/1.0.16.SNAPSHOT, \ >>>>> ssh/4.4.6, \ >>>>> pax-url-wrap/2.6.14, \ >>>>> framework/4.4.6, \ >>>>> system/4.4.6, \ >>>>> feature/4.4.6, \ >>>>> shell/4.4.6, \ >>>>> management/4.4.6, \ >>>>> service/4.4.6, \ >>>>> jaas/4.4.6, \ >>>>> shell-compat/4.4.6, \ >>>>> deployer/4.4.6, \ >>>>> diagnostic/4.4.6, \ >>>>> bundle/4.4.6, \ >>>>> config/4.4.6, \ >>>>> kar/4.4.6 >>>>> >>>>> then it does not get restarted when I install camel. This drives me >>>>> crazy. >>>>> >>>>> >>>>> Maven build says: >>>>> [INFO] Loading boot repositories >>>>> ... >>>>> [INFO] adding feature repository: >>>>> mvn:rahla.feature/rahla.logging/1.0.16-SNAPSHOT/xml/features >>>>> ... >>>>> [INFO] Feature rahla.logging/1.0.16.SNAPSHOT is defined as a boot >>>>> feature >>>>> [INFO] adding maven artifact: >>>>> mvn:com.fasterxml.jackson.core/jackson-annotations/2.15.2 >>>>> [INFO] adding maven artifact: >>>>> mvn:rahla/loki-appender/1.0.16-SNAPSHOT >>>>> [INFO] adding maven artifact: >>>>> mvn:com.fasterxml.jackson.core/jackson-databind/2.15.2 >>>>> [INFO] adding maven artifact: >>>>> mvn:org.ops4j.pax.logging/pax-logging-log4j2-extra/2.2.7 >>>>> [INFO] adding maven artifact: >>>>> mvn:com.fasterxml.jackson.core/jackson-core/2.15.2 >>>>> ... >>>>> >>>>> Boot and installed looks like: >>>>> >>>>> /home/mleinweber/projects/rahla/assembly/pom.xml >>>>> >>>>> All dependency features are scope runtime except rahla.logging which >>>>> is compile >>>>> <bootFeatures> >>>>> <feature>pax-url-wrap</feature> >>>>> <feature>shell</feature> >>>>> <feature>shell-compat</feature> >>>>> <feature>feature</feature> >>>>> <feature>jaas</feature> >>>>> <feature>ssh</feature> >>>>> <feature>management</feature> >>>>> <feature>bundle</feature> >>>>> <feature>config</feature> >>>>> <feature>deployer</feature> >>>>> <feature>diagnostic</feature> >>>>> <feature>feature</feature> >>>>> <feature>instance</feature> >>>>> <feature>kar</feature> >>>>> <feature>log</feature> >>>>> <feature>package</feature> >>>>> <feature>service</feature> >>>>> <feature>system</feature> >>>>> </bootFeatures> >>>>> <installedFeatures> >>>>> <feature>fradi</feature> >>>>> </installedFeatures> >>>>> >>>>> >>>>> Startup works fine >>>>> mvn\:org.apache.karaf.features/org.apache.karaf.features.extension/4.4.6 >>>>> = 1 >>>>> mvn\:org.ops4j.pax.url/pax-url-aether/2.6.14 = 5 >>>>> mvn\:org.ops4j.pax.logging/pax-logging-api/2.2.7 = 8 >>>>> mvn\:com.fasterxml.jackson.core/jackson-annotations/2.15.2 = 8 >>>>> mvn\:org.ops4j.pax.logging/pax-logging-log4j2/2.2.7 = 8 >>>>> mvn\:org.ops4j.pax.logging/pax-logging-log4j2-extra/2.2.7 = 8 >>>>> mvn\:rahla/loki-appender/1.0.16-SNAPSHOT = 8 >>>>> mvn\:com.fasterxml.jackson.core/jackson-core/2.15.2 = 8 >>>>> >>>>> I debugged a bit during build process: >>>>> >>>>> Profile bootOverlay = Profiles.getOverlay(bootProfile, allProfiles, >>>>> environment); >>>>> adds the startup features (my library + "framework") before >>>>> Profile bootEffective = Profiles.getEffective(bootOverlay, false); .. >>>>> and bootEffective.getFeatures() is used >>>>> >>>>> br, >>>>> Matthias >>>>> >>>>> On Tue, 21 May 2024 at 13:29, Grzegorz Grzybek <gr.grzy...@gmail.com> >>>>> wrote: >>>>> >>>>>> Hi >>>>>> >>>>>> compile scopeby default goes to "startup" phase of "profile >>>>>> management". See some comments I've added to Fuse Karaf with >>>>>> karaf-maven-plugin: >>>>>> https://github.com/jboss-fuse/fuse-karaf/blob/7.x.redhat-7-x/assemblies/fuse-karaf/pom.xml#L208-L225 >>>>>> (it's a public repo). >>>>>> >>>>>> So in practice there's no such thing as "startup feature" - simply >>>>>> the bundles from such feature go to etc/startup.properties, preserving >>>>>> start-level attribute of a <bundle> within such <feature>. This should be >>>>>> the way you add a fragment bundle for Pax Logging - as early as possible. >>>>>> >>>>>> Then it is also added to the boot features. >>>>>> >>>>>> >>>>>> Hmm, I'm not sure why's that... Even if it's true (I can't check >>>>>> now), it shouldn't affect the process and cause extra refreshes. >>>>>> In extreme case, where all the features are "startup", you should get >>>>>> all the bundles installed (and active if not fragments) the moment >>>>>> Karaf's >>>>>> FeatureService kicks in... >>>>>> >>>>>> regards >>>>>> Grzegorz Grzybek >>>>>> >>>>>> wt., 21 maj 2024 o 13:15 Matthias Leinweber < >>>>>> m.leinwe...@datatactics.de> napisał(a): >>>>>> >>>>>>> Hello Grzegorz, >>>>>>> >>>>>>> now connecting the dots which jboss fuse and your expert knowledge ;) >>>>>>> >>>>>>> Anyway I shaded the additional library and didn't add the import. >>>>>>> Anyway, a new problem when I add a feature with scope compile to the >>>>>>> startupFeature config. Then it is also added to the boot features. This >>>>>>> causes a restart of pax-logging-log4j2 which causes some trouble with >>>>>>> the >>>>>>> appender code. >>>>>>> >>>>>>> I currently try to see if something like: >>>>>>> >>>>>>> <startupBundles> >>>>>>> <bundle >>>>>>> start-level="8">mvn:org.ops4j.pax.logging/pax-logging-log4j2-extra/${pax-logging.version}</bundle> >>>>>>> <!--mor bundles--> >>>>>>> </startupBundles> >>>>>>> is possible and get rid of the extra feature. But it seems that >>>>>>> start-level is always 30. >>>>>>> >>>>>>> Any ideas? >>>>>>> >>>>>>> On Tue, 21 May 2024 at 11:41, Grzegorz Grzybek <gr.grzy...@gmail.com> >>>>>>> wrote: >>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> `org.osgi.framework.system.packages.extra` can be changed in >>>>>>>> karaf-maven-plugin when building custom Karaf distro. You can also >>>>>>>> provide >>>>>>>> your own config.properties - that's what we do in Fuse Karaf. >>>>>>>> >>>>>>>> But I think the easiest solution for you is to exclude generation >>>>>>>> of such import clause by adding `!sun.nio.ch` if you're not really >>>>>>>> using it in your fragment. >>>>>>>> >>>>>>>> regards >>>>>>>> Grzegorz Grzybek >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> wt., 21 maj 2024 o 10:58 Matthias Leinweber < >>>>>>>> m.leinwe...@datatactics.de> napisał(a): >>>>>>>> >>>>>>>>> I figured out that i added my logging stuff too late.: As a bundle >>>>>>>>> dependency in the assembly with a startup level which is too high (30) >>>>>>>>> which results in a restart of the logging system. Anyway after >>>>>>>>> creating an >>>>>>>>> additional feature with start level 8 and adding it to >>>>>>>>> startupFeatures i am >>>>>>>>> pretty close to a solution. >>>>>>>>> >>>>>>>>> But i get >>>>>>>>> [ERROR] Failed to execute goal >>>>>>>>> org.apache.karaf.tooling:karaf-maven-plugin:4.4.6:assembly >>>>>>>>> (default-assembly) on project rahla: Unable to build assembly: Unable >>>>>>>>> to >>>>>>>>> resolve root: missing requirement [root] osgi.identity; >>>>>>>>> osgi.identity=rahla.logging; type=karaf.feature; >>>>>>>>> version=1.0.16.SNAPSHOT; >>>>>>>>> filter:="(&(osgi.identity=rahla.logging)(type=karaf.feature)(version>=1.0.16.SNAPSHOT))" >>>>>>>>> [caused by: Unable to resolve rahla.logging/1.0.16.SNAPSHOT: missing >>>>>>>>> requirement [rahla.logging/1.0.16.SNAPSHOT] osgi.identity; >>>>>>>>> osgi.identity=org.agrona.core; type=osgi.bundle; >>>>>>>>> version="[1.12.0,1.12.0]"; >>>>>>>>> resolution:=mandatory [caused by: Unable to resolve >>>>>>>>> org.agrona.core/1.12.0: >>>>>>>>> missing requirement [org.agrona.core/1.12.0] osgi.wiring.package; >>>>>>>>> filter:="(osgi.wiring.package=sun.nio.ch)"]] >>>>>>>>> >>>>>>>>> I am currently digging through the source code to see if I can >>>>>>>>> change org.osgi.framework.system.packages.extra during execution of >>>>>>>>> the >>>>>>>>> plugin? Or does anyone know a better solution? >>>>>>>>> >>>>>>>>> br, >>>>>>>>> Matthias >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Sat, 18 May 2024 at 10:33, Matthias Leinweber < >>>>>>>>> m.leinwe...@datatactics.de> wrote: >>>>>>>>> >>>>>>>>>> Thank you for the support. Worked like a charm. >>>>>>>>>> >>>>>>>>>> Grzegorz Grzybek <gr.grzy...@gmail.com> schrieb am Sa., 18. Mai >>>>>>>>>> 2024, 08:47: >>>>>>>>>> >>>>>>>>>>> Hi >>>>>>>>>>> >>>>>>>>>>> You should not get this file from original jar - it has to be >>>>>>>>>>> generated using Maven configuration of two Maven plugins: >>>>>>>>>>> >>>>>>>>>>> - maven-compiler-plugin to configure >>>>>>>>>>> >>>>>>>>>>> org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor >>>>>>>>>>> - maven-bundle-plugin to ensure resource mapping: >>>>>>>>>>> >>>>>>>>>>> META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat=target/classes/META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat >>>>>>>>>>> >>>>>>>>>>> See: >>>>>>>>>>> https://github.com/ops4j/org.ops4j.pax.logging/blob/main/pax-logging-samples/fragment-log4j2/pom.xml#L41-L77 >>>>>>>>>>> >>>>>>>>>>> regards >>>>>>>>>>> Grzegorz Grzybek >>>>>>>>>>> >>>>>>>>>>> pt., 17 maj 2024 o 19:28 Matthias Leinweber < >>>>>>>>>>> m.leinwe...@datatactics.de> napisał(a): >>>>>>>>>>> >>>>>>>>>>>> Ok, it doesn't seem so complicated.. Anyway, my java skills are >>>>>>>>>>>> a bit outdated. Working with private-package looks good in the >>>>>>>>>>>> first place. >>>>>>>>>>>> But how do I get the Log4j2Plugins.dat out of the original jar >>>>>>>>>>>> into my >>>>>>>>>>>> bundle? >>>>>>>>>>>> >>>>>>>>>>>> On Fri, 17 May 2024 at 16:55, Grzegorz Grzybek < >>>>>>>>>>>> gr.grzy...@gmail.com> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hello >>>>>>>>>>>>> >>>>>>>>>>>>> You can find a sample fragment here: >>>>>>>>>>>>> https://github.com/ops4j/org.ops4j.pax.logging/tree/main/pax-logging-samples/fragment-log4j2 >>>>>>>>>>>>> That's all there is ;( >>>>>>>>>>>>> >>>>>>>>>>>>> regards >>>>>>>>>>>>> Grzegorz Grzybek >>>>>>>>>>>>> >>>>>>>>>>>>> pt., 17 maj 2024 o 16:26 Matthias Leinweber < >>>>>>>>>>>>> m.leinwe...@datatactics.de> napisał(a): >>>>>>>>>>>>> >>>>>>>>>>>>>> Hello Karaf Team, >>>>>>>>>>>>>> >>>>>>>>>>>>>> is it possible to directly add a custom log4j2 appender via >>>>>>>>>>>>>> wrap protocol? >>>>>>>>>>>>>> >>>>>>>>>>>>>> I added log4j2.packages = pl.tkowalcz.tjahzi.log4j2 to >>>>>>>>>>>>>> org.ops4j.pax.logging.cfg but i get ERROR : Unable to locate >>>>>>>>>>>>>> plugin for Loki >>>>>>>>>>>>>> >>>>>>>>>>>>>> I fear that i have to build a fragment bundle for pax logging >>>>>>>>>>>>>> .. if yes where can i find some doc? >>>>>>>>>>>>>> >>>>>>>>>>>>>> br. >>>>>>>>>>>>>> Matthias >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>> >>>>> >>>>> >>> >>> >>> > > >