[SCR] Found components with duplicated names inside their bundle!

Today I was briefly confused by an error message issued by the OSGi Equinox runtime’s Declarative Services runtime which I did not understand immediately. For your – and my own – reference find the solution here.
First, this was the error message I got:

1281104579615=1::[SCR] Found components with duplicated names inside their bundle!
This component will not be processed: Component[
name = networksimulation
factory = null
autoenable = true
immediate = true
implementation = com.danielschneller.sim.network.NetworkStateSimulation
properties = {devicevendor=DanielSchneller, simulation=true}
serviceFactory = false
serviceInterface = [com.danielschneller.network.NetworkState]
references = {
Reference[name = LOG, interface = org.osgi.service.log.LogService,
policy = static, cardinality = 0..1, target = null, bind = null, unbind = null]
}
located in bundle = com.danielschneller.sim.network_1.1.0.qualifier [49]
]

Apparently the component name networksimulation was used by two components in the same bundle. Well, that’s why you are encouraged to use package-name like identifiers; however this was not the problem. Changing it to com.danielschneller.sim.net.simulation which was guaranteed to be unique in my case still left the error the same:

1281104579615=1::[SCR] Found components with duplicated names inside their bundle!
This component will not be processed: Component[
name = com.danielschneller.sim.net.simulation
factory = null
...

To make it short, this is what happened: I had added this component’s description to a bundle that already contained some more using the Eclipse wizard for new service components.
That very fine wizard dutifully added the new filename to the Manifest is the Service-Component: line. Unfortunately in this case it led to:

Service-Component: OSGI-INF/*.xml, networksimulation.xml

At launch time apparently the wildcard was expanded, already including the new file, and then added at the end again. Apparently there is no sanitizing done (like adding the filenames to a Set instead of a List), which results in a second attempt of registering the same component a second time. I will go and file a bug with Eclipse for this, There already is a filed, but unfixed bug for this (Eclipse Bug #278540) but till then just make sure that when you use wildcards in the Service-Component Manifest header it does not cause any duplicates.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值