Multiple references with the same name at maven-bundle-plugin

懵懂的女人 提交于 2021-02-10 18:11:46

问题


I'm using the maven-bundle-plugin 3.3.0 and OSGI R6.

I have the following classes:

//Class A
@Component (immediate = true, service = {})
public class A{
    private static B myB;
    @Reference (unbind = "unbindB")
    public static void bindB(B pB)
    {
        myB = pB;
    }

    public static void unbindB()
    {
        myB= null;
    }
}



//B class. It does not implement any interface. Hence, the service must be itself
@Component (immediate = true, service = B.class)
public class B{
@Activate
    public void activate(){
        //B activated
    }
}

After running mvn clean install, the maven-bundle-plugin 3.3.0 gives me the error:

Bundle com.X:bundle:0.0.1-SNAPSHOT : In component com.X.A, multiple references with the same name: myB. Previous def: com.X.B, this def:
[ERROR] Error(s) found in bundle configuration

Does any of you know what could it be wrong?


回答1:


The bind/unbind methods cannot be static. Your code shows them as static. DS components are always instance based.



来源:https://stackoverflow.com/questions/47925047/multiple-references-with-the-same-name-at-maven-bundle-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!