javamavenosgiosgi-bundlemaven-bundle-plugin

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


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?


Solution

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