Search code examples
javaosgibundleapache-felix

Start OSGI bundle from Felix shell: Unresolved constraint


I'm trying to execute OSGI bundles with felix. However, I'm not even able to start the bundle. I have an error on the shell command.

This is the pom.xml of the bundle:

<project>
  <modelVersion>4.0.0</modelVersion>
  <packaging>bundle</packaging>
  <groupId>gateway</groupId>
  <artifactId>home.interfaces</artifactId>
  <version>1.0.0</version>
  <name>Interface Service Provider</name>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.0.1</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>
              ${pom.artifactId}
            </Bundle-SymbolicName>
        <Export-Package>
                 temp;pres
            </Export-Package>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-ipojo-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>ipojo-bundle</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

and this is the error in the command shell:

Welcome to Felix
================

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (2.0.4)
[   1] [Active     ] [    1] Apache Felix Bundle Repository (1.4.3)
[   2] [Active     ] [    1] Apache Felix Shell Service (1.4.2)
[   3] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
[   4] [Installed  ] [    1] Interface Service Provider (1.0.0)
[   5] [Installed  ] [    1] Presence Service Provider (1.0.0)
[   6] [Installed  ] [    1] Temperature Service Provider (1.0.0)
[   7] [Installed  ] [    1] Analyser Service (1.0.0)
-> start 4
org.osgi.framework.BundleException: Unresolved constraint in bundle home.interfa
ces [4]: package; (&(package=org.osgi.service.cm)(version>=1.2.0))
->

What is this error and how do I fix it?


Solution

  • You are trying to start bundle #4 that as the error shows depends on an external bundle that exports org.osgi.service.cm with version>=1.2.0, you don't have it in your list.

    The weird thing is that i don't see any import-package statement in your pom.xml, btw, that bundle is the Felix Configuration Admin Service, install it and if there aren't other missing dependencies it should start correctly.