Eclipse feature based launch unable to resolve dependency

756 Views Asked by At

I have an OSGI bundle that depends on a package, which is exposed through a feature. The package I depend on requires a specific version of a bundle, say com.company.antlr.runtime (3.0.1). The feature in turn packages two versions of the bundle, com.company.antlr.runtime (3.0.1) and com.company.antlr.runtime (3.2.0).

The problem is that when I make a feature based launch configuration in Eclipse with my bundle (in a feature) and the feature containing the package I depend on, I get a missing constraint validation error stating that the required bundle com.company.antlr.runtime(3.0.1) is missing.

Adding com.company.antlr.runtime (3.0.1) as a bundle to the feature launch has no effect, I still get the same validation error.

If, on the other hand, I make a bundle based launch configuration including the exact same bundles as those packaged in the feature there is no validation problem.

The problem can be illustrated with this minimal example:

The bundle org.example.examplebundle has the manifest:

Manifest-Version: 1.0 
Bundle-ManifestVersion: 2 
Bundle-Name:Examplebundle 
Bundle-SymbolicName: org.example.examplebundle 
Bundle-Version:1.0.0.qualifier 
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 
Require-Bundle: com.company.antlr.runtime;bundle-version="[3.0.1,3.0.1]"

And the feature org.example.examplefeature has the feature.xml:

<feature
      id="org.example.examplefeature"
      label="Examplefeature"
      version="1.0.0.qualifier">

   <plugin
         id="org.eclipse.osgi"
         download-size="0"
         install-size="0"
         version="0.0.0"
         unpack="false"/>

   <plugin
         id="org.example.examplebundle"
         download-size="0"
         install-size="0"
         version="0.0.0"
         unpack="false"/>

   <plugin
         id="com.company.antlr.runtime"
         download-size="0"
         install-size="0"
         version="3.0.1"
         unpack="false"/>

   <plugin
         id="com.company.antlr.runtime"
         download-size="0"
         install-size="0"
         version="3.2.0"
         unpack="false"/>

</feature>

Making a feature based launch with just this feature will lead to the validation error. Making a bundle based launch with the four bundles included in the feature does NOT give a validation error.

I then tried adding the necessary bundles for using the console and removing the bundle org.example.examplebundle from the feature org.example.examplefeature and then running it using the feature based launch. I then observed that the bundle com.company.antlr.runtime (3.0.1) was not started at all.

If I add the same necessary bundles to the bundle based launch I can observe that both com.company.antlr.runtime (3.0.1) and com.company.antlr.runtime (3.2.0) are active.

My guess based on this is that the resolver for the feature based launch concludes that the bundle with the highest version number is sufficient, and therefore doesn't start the older version at all.

With that hypothesis in mind, I tried to state explicitly in the feature.xml that I need a perfect match for com.company.antlr.runtime (3.0.1) by including the following snippet in the feature.xml:

  <requires>
    <import 
      plugin="com.company.antlr.runtime"
      version="3.0.1"
      match="perfect"
      />
   </requires>

But, alas, to no avail.

So, my question now is: is there any way to solve this problem while keeping the feature based launch?

For completeness: I am running Eclipse Kepler 4.3 and OSGI 3.8.1

1

There are 1 best solutions below

2
On

it seems that you are setting the auto-start to true for the two bundles when using Bundle based launcher. You can't do the same when using Feature based launcher unless you have set "Default Auto-Start" true or create a Product definition and set a start level for those bundles.