1

I have a basic OSGI project in Eclipse. When I created a class Activator and imported the BundleActivator, Eclipse changed the MANIFEST.MF adding these lines:

Export-Package: my.package.name;uses:="org.osgi.framework";version="0.0.1.SNAPSHOT" Import-Package: org.osgi.framework;version="[1.8,2)" 

Now Eclipse ("problems view") prompts this error message:

Unsatisfied constraint: 'Import-Package: org.osgi.framework; version="[1.8.0,2.0.0)"' Plug-in Problem MANIFEST.MF 

I have imported the newest Apache Felix runtime and it can be found as a Maven dependency, but that does not solve the problem, when running from within Eclipse.

What do I need to change to solve the dependency? Why does it print versions 1.8.0,2.0.0?

Update

Plugin part of pom.xml:

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.3.7</version> <configuration> <manifestLocation>src/main/resources/META-INF</manifestLocation> <rebuildBundle>true</rebuildBundle> <instructions> <Bundle-Activator>my.package.name.Activator</Bundle-Activator> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment> </instructions> </configuration> <!-- EXECUTION --> <extensions>true</extensions> <executions> <execution> <id>set_failok</id> <goals> <goal>manifest</goal> </goals> <configuration> <instructions> <_failok>true</_failok> </instructions> </configuration> </execution> </executions> </plugin> 

Dependency part of pom.xml (import works well):

<dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.framework</artifactId> <version>5.0.0</version> </dependency> 
4
  • Can you show us your pom.xml? How are you trying to use OSGi? [1.8.0,2.0.0) means "any version from 1.8.0 (inclusive) to 2.0.0 (exclusive). This is how OSGi versioning works. Commented Jun 9, 2015 at 12:11
  • that's odd, I don't have eclipse changing the manifest.mf when adding an activator... Commented Jun 9, 2015 at 12:11
  • I used right click "Configure" -> "Convert to OSGI Bundle". After that the project facet "Osgi Bundle" is set and the manifest file is changed automatically. Commented Jun 9, 2015 at 12:23
  • 1
    Eclipse does not change the Manifest. The maven bundle plugin creates it. If you use the maven bundle plugin then you normally do not edit the Manifest by hand at all. Commented Jun 9, 2015 at 12:38

1 Answer 1

1

The maven bundle plugin looks into the manifests of the bundles you depend on to determine the package versions.

it finds that you use the package org.osgi.framework and that felix framework 5.0.0 exports this package with version 1.8.0. So it creates an import range from this version until excluding the next major version.

So your Manifest looks good. The reason why you can not run from eclipse might be that you use a lower OSGi framework version there that does not offer the 1.8.0 version of the above package. Try to run with felix framework 5.0.0.

Sign up to request clarification or add additional context in comments.

2 Comments

Indeed, after downgrading Felix to 4.0.0 the import changes to (1.6,2) and it works. Thanks a lot!
Even better, don't compile against a specific OSGi Framework implementation such as Felix, but use one of the OSGi Specification JARS (osgi.core-<version>.jar) that can be downloaded from the OSGi Alliance website, osgi.org.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.