1

I am trying to create a composite component using iPOJO API.

Initially, I embed felix framework in my java application as the following:

public class HostApplication
{
    private HostActivator m_activator = null;
    private Felix m_felix = null;


    public HostApplication()
    {
        Map config= new HashMap();

        // Create a configuration property map.
        //Map config = new HashMap();
        config.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
        // Create host activator;
        m_activator = new HostActivator();
        List list = new ArrayList();
        list.add(m_activator);


        config.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
         try
        {
            // Now create an instance of the framework with
            // our configuration properties.
            m_felix = new Felix(config);
            // Now start Felix instance.
            m_felix.start();
        }
        catch (Exception ex)
        {
            System.err.println("Could not create framework: " + ex);
            ex.printStackTrace();
        }


        // Register the application's context as an OSGi service!
        BundleContext bundleContext1 = m_felix.getBundleContext();

        ............

I also deploy iPOJO required bundles in my java application as the following:

  //starting ipojo required bundles
                    Bundle coreBundle = bundleContext1.installBundle("file:C:\\Users\\zaid.almahmoud\\Dropbox\\EBTIC\\ADERE\\feasibility-codes\\ipojo\\ipojo-distribution-1.11.0\\bundle\\org.apache.felix.ipojo-1.11.0.jar");
                    coreBundle.start();

                    Bundle compositeBundle = bundleContext1.installBundle("file:C:\\Users\\zaid.almahmoud\\Dropbox\\EBTIC\\ADERE\\feasibility-codes\\ipojo\\ipojo-distribution-1.11.0\\bundle\\org.apache.felix.ipojo.composite-1.6.0.jar");
                    compositeBundle.start();


                    Bundle apiBundle = bundleContext1.installBundle("file:C:\\Users\\zaid.almahmoud\\Dropbox\\EBTIC\\ADERE\\feasibility-codes\\ipojo\\ipojo-distribution-1.11.0\\bundle\\org.apache.felix.ipojo.api-1.6.0.jar");
                    apiBundle.start();

Below is a snapshot of the jars in my java application class-path:

enter image description here

In addition to my java application, I have a bundle in which I create a composite component type using iPOJO API. I create this composite and makes an instance of it in my bundle Activator start method, as the following:

  public void start(BundleContext context) throws Exception {

      CompositeComponentType type = new CompositeComponentType()
      .setBundleContext(context)
      .setComponentTypeName("comp1");

      ComponentInstance ci = type.createInstance();
}

MANIFEST.MF of my bundle:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Starter
Bundle-SymbolicName: starter
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: starter.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
 org.apache.felix.ipojo-1.6.0.jar,
 org.apache.felix.ipojo.api-1.6.0.jar,
 org.apache.felix.ipojo.composite-1.6.0.jar
Export-Package: org.apache.felix.ipojo
Import-Package: org.osgi.framework, org.apache.felix.ipojo

My bundle class-path:

enter image description here

When I install and start this bundle in my java application, I get the following error:

org.osgi.framework.BundleException: Activator start error in bundle starter...
Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.felix.ipojo.composite.CompositeFactory.check(Lorg/apache/felix/ipojo/metadata/Element;)V" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, org/apache/felix/ipojo/composite/CompositeFactory, and its superclass loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5), have different Class objects for the type y.check(Lorg/apache/felix/ipojo/metadata/Element;)V used in the signature

at the following line:

ComponentInstance ci = type.createInstance();

I read here that this error might come when you have two identical classes in two bundles. But I could not figure out where these two classes could be. I suspected org/apache/felix/ipojo/metadata/Element but I found only one class in org.apache.felix.ipojo.. I don't have that library anywhere else except in my bundle.

Can you please help? Thanks.

Krease
  • 15,805
  • 8
  • 54
  • 86
Traveling Salesman
  • 2,209
  • 11
  • 46
  • 83

0 Answers0