在karaf中安装scr功能后,将调用activate方法两次

时间:2015-11-08 15:04:14

标签: java osgi apache-karaf karaf

我正在尝试使用apache-karaf 2.3.10安装一个OSGi包,我已在此link中发布了该示例。我做了以下步骤

1. Downloaded apache-karaf version 2.3.10 
2. Executed the command features:install scr. Successfully installed scr. I have verified by executing scr:list
3. Installed all the bundles
4. Finally after starting all the bundles activate method in ExampleComponentFactoryManager  called twice and two objects are created. I have verified the same by executing the command scr:list
5. After uninstalling the scr feature the activate method in ExampleComponentFactoryManager called only once which is the expected behaviour.
6. Also i have noted that upto apache-karaf-2.3.10 while installing the scr feature it fetches from the online repo. But from 2.3.11 i am getting error because it tries to fetch it from my maven repository. The error is shown the console.

有人能告诉我karaf中的功能scr会发生什么吗? 因为使用scr功能,我可以看到karaf中可用的工厂和实例。这是预期的吗?

1 个答案:

答案 0 :(得分:1)

您可以检查是否有两个felix scr包运行的实例。这可以解释双重对象的创建。