[ 
https://issues.apache.org/jira/browse/FELIX-6090?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ashish Chopra updated FELIX-6090:
---------------------------------
    Description: 
Since the resolution of FELIX-4596, support for appending or prepending the 
Manifest Headers via bundle-plugin's build instructions exist. maven-scr-plugin 
leverages that and via FELIX-4595 it now has the support to append the 
{{Service-Component}} header.

However, this takes away the functionality to provide a Header _entirelly_ via 
the build-instructions for the project POM. Notably for {{Service-Component}} 
header, this becomes important when the OSGi bundle created by the project's 
POM has to serve as a host-bundle of one or more OSGi fragment-bundles.
If the fragment bundles have their own OSGi components, one way to activate 
them is via [0] (as discussed at [1] [2]). But due to "append" nature of 
entries generated by maven-scr-plugin, the final {{Service-Component}} header 
in the MANIFEST looks like [3], which causes Felix SCR to attempt the 
activation of the OSGi component twice. This causes a (benign) {{ERROR}} 
log-line to appear [4].

I tried going through the changelogs of maven-bundle-plugin and 
maven-scr-plugin, but couldn't find any further development on this topic.

Raising this JIRA to review the addition of such a capability (maybe enhance 
maven-bundle-plugin instructions to optionally ignore requests to update 
headers, or otherwise provide a mechanism to prepend/append 'auto-generated' 
{{Service-Component}} entries to those specified in POM like 
{{maven-resources}} directive for {{Include-Resource}} manifest-header)

[0]
{noformat}
<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <Service-Component>
        OSGI-INF/*.xml
      </Service-Component>
    </instructions>
  </configuration>
</plugin>
{noformat}
[1] http://apache-felix.18485.x6.nabble.com/DS-amp-fragments-td5004610.html
[2] https://stackoverflow.com/a/42062399
[3] 
{noformat}
Service-Component: 
OSGI-INF/*.xml,OSGI-INF/com.example.my.package1.Service1.xml,OSGI-INF/com.example.my.package1.Service2.xml,OSGI-INF/com.example.my.package2.Service.xml
{noformat}
[4]
{noformat}
*ERROR* [FelixStartLevel] com.example.my-bundle bundle 
com.example.my-bundle:1.0.1.SNAPSHOT (331)[com.example.my.package1.Service1] :  
Cannot register component (org.osgi.service.component.ComponentException: The 
component name 'com.example.my.package1.Service1' has already been registered 
by Bundle 331 (com.example.my-bundle) as Component of Class 
com.example.my.package1.Service1)
org.osgi.service.component.ComponentException: The component name 
'com.example.my.package1.Service1' has already been registered by Bundle 331 
(com.example.my-bundle) as Component of Class com.example.my.package1.Service1
    at 
org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:239)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:442)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:314)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:269)
 [org.apache.felix.scr:2.1.16]
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:380) 
[org.apache.felix.scr:2.1.16]
    at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) 
[org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) 
[org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49)
 [org.apache.felix.scr:2.1.16]
    at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)
    at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:420)
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
    at 
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
    at 
org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
    at 
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
    at 
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4817)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2336)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
    at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.lang.Thread.run(Thread.java:748)
{noformat}

  was:
Since the resolution of FELIX-4596, support for appending or prepending the 
Manifest Headers via bundle-plugin's build instructions exist. maven-scr-plugin 
leverages that and via FELIX-4595 it now has the support to append the 
{{Service-Component}} header.

However, this takes away the functionality to provide a Header _entirelly_ via 
the build-instructions for the project POM. Notably for {{Service-Component}} 
header, this becomes important when the OSGi bundle created by the project's 
POM has to serve as a host-bundle of one or more OSGi fragment-bundles.
If the fragment bundles have their own OSGi components, one way to activate 
them is via [0] (as discussed at [1] [2]). But due to "append" nature of 
entries generated by maven-scr-plugin, the final {{Service-Component}} header 
in the MANIFEST looks like [3], which causes Felix SCR to attempt the 
activation of the OSGi component twice. This causes a (benign) {{ERROR}} 
log-line to appear [4].

I tried going through the changelogs of maven-bundle-plugin and 
maven-scr-plugin, but couldn't find any further development on this topic.

Raising this JIRA to review the addition of such a capability (maybe enhance 
maven-bundle-plugin instructions to optionally ignore requests to update 
headers)

[0]
{noformat}
<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <Service-Component>
        OSGI-INF/*.xml
      </Service-Component>
    </instructions>
  </configuration>
</plugin>
{noformat}
[1] http://apache-felix.18485.x6.nabble.com/DS-amp-fragments-td5004610.html
[2] https://stackoverflow.com/a/42062399
[3] 
{noformat}
Service-Component: 
OSGI-INF/*.xml,OSGI-INF/com.example.my.package1.Service1.xml,OSGI-INF/com.example.my.package1.Service2.xml,OSGI-INF/com.example.my.package2.Service.xml
{noformat}
[4]
{noformat}
*ERROR* [FelixStartLevel] com.example.my-bundle bundle 
com.example.my-bundle:1.0.1.SNAPSHOT (331)[com.example.my.package1.Service1] :  
Cannot register component (org.osgi.service.component.ComponentException: The 
component name 'com.example.my.package1.Service1' has already been registered 
by Bundle 331 (com.example.my-bundle) as Component of Class 
com.example.my.package1.Service1)
org.osgi.service.component.ComponentException: The component name 
'com.example.my.package1.Service1' has already been registered by Bundle 331 
(com.example.my-bundle) as Component of Class com.example.my.package1.Service1
    at 
org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:239)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:442)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:314)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:269)
 [org.apache.felix.scr:2.1.16]
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:380) 
[org.apache.felix.scr:2.1.16]
    at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) 
[org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) 
[org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169)
 [org.apache.felix.scr:2.1.16]
    at 
org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49)
 [org.apache.felix.scr:2.1.16]
    at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)
    at 
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:420)
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
    at 
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
    at 
org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
    at 
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
    at 
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4817)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2336)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
    at 
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
    at java.lang.Thread.run(Thread.java:748)
{noformat}


> No way to provide non-override-able instructions to maven-bundle-plugin
> -----------------------------------------------------------------------
>
>                 Key: FELIX-6090
>                 URL: https://issues.apache.org/jira/browse/FELIX-6090
>             Project: Felix
>          Issue Type: Improvement
>          Components: Maven Bundle Plugin
>    Affects Versions: maven-bundle-plugin-4.1.0
>            Reporter: Ashish Chopra
>            Priority: Major
>
> Since the resolution of FELIX-4596, support for appending or prepending the 
> Manifest Headers via bundle-plugin's build instructions exist. 
> maven-scr-plugin leverages that and via FELIX-4595 it now has the support to 
> append the {{Service-Component}} header.
> However, this takes away the functionality to provide a Header _entirelly_ 
> via the build-instructions for the project POM. Notably for 
> {{Service-Component}} header, this becomes important when the OSGi bundle 
> created by the project's POM has to serve as a host-bundle of one or more 
> OSGi fragment-bundles.
> If the fragment bundles have their own OSGi components, one way to activate 
> them is via [0] (as discussed at [1] [2]). But due to "append" nature of 
> entries generated by maven-scr-plugin, the final {{Service-Component}} header 
> in the MANIFEST looks like [3], which causes Felix SCR to attempt the 
> activation of the OSGi component twice. This causes a (benign) {{ERROR}} 
> log-line to appear [4].
> I tried going through the changelogs of maven-bundle-plugin and 
> maven-scr-plugin, but couldn't find any further development on this topic.
> Raising this JIRA to review the addition of such a capability (maybe enhance 
> maven-bundle-plugin instructions to optionally ignore requests to update 
> headers, or otherwise provide a mechanism to prepend/append 'auto-generated' 
> {{Service-Component}} entries to those specified in POM like 
> {{maven-resources}} directive for {{Include-Resource}} manifest-header)
> [0]
> {noformat}
> <plugin>
>   <groupId>org.apache.felix</groupId>
>   <artifactId>maven-bundle-plugin</artifactId>
>   <extensions>true</extensions>
>   <configuration>
>     <instructions>
>       <Service-Component>
>         OSGI-INF/*.xml
>       </Service-Component>
>     </instructions>
>   </configuration>
> </plugin>
> {noformat}
> [1] http://apache-felix.18485.x6.nabble.com/DS-amp-fragments-td5004610.html
> [2] https://stackoverflow.com/a/42062399
> [3] 
> {noformat}
> Service-Component: 
> OSGI-INF/*.xml,OSGI-INF/com.example.my.package1.Service1.xml,OSGI-INF/com.example.my.package1.Service2.xml,OSGI-INF/com.example.my.package2.Service.xml
> {noformat}
> [4]
> {noformat}
> *ERROR* [FelixStartLevel] com.example.my-bundle bundle 
> com.example.my-bundle:1.0.1.SNAPSHOT (331)[com.example.my.package1.Service1] 
> :  Cannot register component (org.osgi.service.component.ComponentException: 
> The component name 'com.example.my.package1.Service1' has already been 
> registered by Bundle 331 (com.example.my-bundle) as Component of Class 
> com.example.my.package1.Service1)
> org.osgi.service.component.ComponentException: The component name 
> 'com.example.my.package1.Service1' has already been registered by Bundle 331 
> (com.example.my-bundle) as Component of Class com.example.my.package1.Service1
>     at 
> org.apache.felix.scr.impl.ComponentRegistry.checkComponentName(ComponentRegistry.java:239)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:442)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:314)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:269)
>  [org.apache.felix.scr:2.1.16]
>     at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:380) 
> [org.apache.felix.scr:2.1.16]
>     at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) 
> [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:264) 
> [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49)
>  [org.apache.felix.scr:2.1.16]
>     at 
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)
>     at 
> org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:420)
>     at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
>     at 
> org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
>     at 
> org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
>     at 
> org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
>     at 
> org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
>     at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4817)
>     at org.apache.felix.framework.Felix.startBundle(Felix.java:2336)
>     at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
>     at 
> org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
>     at java.lang.Thread.run(Thread.java:748)
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to