Reputation: 4414
I am running through the book "OSGi and Apache Felix 3.0" and have hit a problem where a bundle I am deploying insists that it has a dependency on the wrong version of another bundle. For anyone who has worked through these examples before, I am just at the end of chapter 10 - implementing logging functionality in the Bookshelf Service Bundle.
Basically the problem is as follows:
I have a bundle called "Bookshelf Service" to which I have just added some sweet new logging functionality. This new functionality puts it at version 1.10.0
I have another bundle called "Bookshelf Service Gogo commands" which is a command-line interface to functionality in "Bookshelf Service". It is at version 1.9.0.
What is puzzling is that when I deploy the "Bookshelf Service Gogo commands" bundle, it installs as follows:
deploy -s "Bookshelf Service Gogo commands"
Target resource(s):
-------------------
Bookshelf Service Gogo commands (1.9.0)
Required resource(s):
---------------------
Bookshelf Service (1.7.0)
Which of course is the wrong version of the 'Bookshelf Service' Bundle. I want to be using version 1.10.0.
If I update, or force the framework to use version 1.10.0, then the functionality that "Bookshelf Service Gogo commands" offers ceases to be available. It is refusing to work with the newest version of 'Bookshelf Service'.
According to the pom.xml file though, the dependency is indeed for the 1.10.0 version of 'Bookshelf Service'. The POM for "Bookshelf Service Gogo commands" is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packtpub.felix</groupId>
<artifactId>com.packtpub.felix.bookshelf-service-tui</artifactId>
<version>1.9.0</version>
<packaging>bundle</packaging>
<name>Bookshelf Service Gogo commands</name>
<description>The text user-interface</description>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.runtime</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.annotations</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>com.packtpub.felix</groupId>
<artifactId>com.packtpub.felix.bookshelf-service</artifactId>
<version>1.10.0</version>
<type>bundle</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Category>sample</Bundle-Category>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
com.packtpub.felix.bookshelf.service.tui
</Export-Package>
<!-- <Bundle-Activator>
com.packtpub.felix.bookshelf.service.tui.activator.BookshelfTuiActivator
</Bundle-Activator>
<Private-Package>
com.packtpub.felix.bookshelf.service.tui.activator
</Private-Package>
-->
</instructions>
<remoteOBR>repo-rel</remoteOBR>
<prefixUrl>file:/home/awalker/sandbox_workspace/releases</prefixUrl>
<ignoreLock>true</ignoreLock>
</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>
<configuration>
<metadata>src/main/ipojo/meta.xml</metadata>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<!-- releases repo -->
<repository>
<id>repo-rel</id>
<url>file:/home/awalker/sandbox_workspace/releases</url>
</repository>
</distributionManagement>
</project>
So I don't understand why it only wants to work with 1.7.0.
It is also worth mentioning that both of these bundles are taking advantage of iPOJO, so they do have meta.xml files. I don't think the problem is there however, because I have been comparing my code to the downloadable sample code for the book examples, and everything seems to match.
Any ideas about what is going wrong, or where to look for the source of this problem?
EDIT:
As per request, the generated manifests.
Bookshelf Service 1.7.0:
Manifest-Version: 1.0
Export-Package: com.packtpub.felix.bookshelf.service.api;uses:="com.pa
cktpub.felix.bookshelf.inventory.api",com.packtpub.felix.bookshelf.se
rvice.impl;uses:="com.packtpub.felix.bookshelf.inventory.api,com.pack
tpub.felix.bookshelf.service.api,org.osgi.framework"
Built-By: awalker
Tool: Bnd-0.0.357
Bundle-Category: sample
Bundle-Name: Bookshelf Service
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.6.0_24
Bundle-Version: 1.7.0
Bnd-LastModified: 1305055936964
Bundle-ManifestVersion: 2
Bundle-Activator: com.packtpub.felix.bookshelf.service.impl.activator.
BookshelfServiceImplActivator
Bundle-Description: This Bookshelf Service
Bundle-SymbolicName: com.packtpub.felix.bookshelf-service
Import-Package: com.packtpub.felix.bookshelf.inventory.api,com.packtpu
b.felix.bookshelf.service.api,com.packtpub.felix.bookshelf.service.im
pl,org.osgi.framework;version="1.5"
Bookshelf Service version 1.10.0
Manifest-Version: 1.0
Export-Package: com.packtpub.felix.bookshelf.service.api;uses:="com.pa
cktpub.felix.bookshelf.inventory.api",com.packtpub.felix.bookshelf.se
rvice.impl;uses:="com.packtpub.felix.bookshelf.inventory.api,com.pack
tpub.felix.bookshelf.service.api,com.packtpub.felix.bookshelf.log.api
"
iPOJO-Components: component { $immediate="true" $name="BookshelfServic
eImpl" $classname="com.packtpub.felix.bookshelf.service.impl.Bookshel
fServiceImpl" provides { }manipulation { field { $name="sessionId" $t
ype="java.lang.String" }field { $name="inventory" $type="com.packtpub
.felix.bookshelf.inventory.api.BookInventory" }field { $name="logger"
$type="com.packtpub.felix.bookshelf.log.api.BookshelfLogHelper" }met
hod { $name="$init" }method { $name="getLogger" $return="com.packtpub
.felix.bookshelf.log.api.BookshelfLogHelper" }method { $name="lookupB
ookInventory" $return="com.packtpub.felix.bookshelf.inventory.api.Boo
kInventory" }method { $arguments="{java.lang.String,char[]}" $name="l
ogin" $return="java.lang.String" }method { $arguments="{java.lang.Str
ing}" $name="logout" }method { $arguments="{java.lang.String}" $name=
"sessionIsValid" $return="boolean" }method { $arguments="{java.lang.S
tring}" $name="checkSession" }method { $arguments="{java.lang.String,
java.lang.String}" $name="getBook" $return="com.packtpub.felix.booksh
elf.inventory.api.Book" }method { $arguments="{java.lang.String,java.
lang.String}" $name="getBookForEdit" $return="com.packtpub.felix.book
shelf.inventory.api.MutableBook" }method { $arguments="{java.lang.Str
ing,java.lang.String,java.lang.String,java.lang.String,java.lang.Stri
ng,int}" $name="addBook" }method { $arguments="{java.lang.String,java
.lang.String,java.lang.String}" $name="modifyBookCategory" }method {
$arguments="{java.lang.String,java.lang.String,int}" $name="modifyBoo
kRating" }method { $arguments="{java.lang.String}" $name="getCategori
es" $return="java.util.Set" }method { $arguments="{java.lang.String,j
ava.lang.String}" $name="removeBook" }method { $arguments="{java.lang
.String,java.lang.String}" $name="searchBooksByAuthor" $return="java.
util.Set" }method { $arguments="{java.lang.String,java.lang.String}"
$name="searchBooksByCategory" $return="java.util.Set" }method { $argu
ments="{java.lang.String,java.lang.String}" $name="searchBooksByTitle
" $return="java.util.Set" }method { $arguments="{java.lang.String,int
,int}" $name="searchBooksByRating" $return="java.util.Set" }interface
{ $name="com.packtpub.felix.bookshelf.service.api.BookshelfService"
}}requires { $field="inventory" }requires { $field="logger" }}instanc
e { $component="BookshelfServiceImpl" $name="bookshelf.service.impl"
}
Built-By: awalker
Tool: Bnd-0.0.357
Bundle-Category: sample
Bundle-Name: Bookshelf Service
Created-By: Apache Maven Bundle Plugin & iPOJO 1.6.0
Build-Jdk: 1.6.0_24
Bundle-Version: 1.10.0
Bnd-LastModified: 1305656960793
Bundle-ManifestVersion: 2
Bundle-Description: This Bookshelf Service
Import-Package: com.packtpub.felix.bookshelf.inventory.api, org.osgi.s
ervice.log;version=1.3, com.packtpub.felix.bookshelf.service.impl, co
m.packtpub.felix.bookshelf.service.api, org.apache.felix.ipojo.archit
ecture;version= 1.6.0, com.packtpub.felix.bookshelf.log.api, org.apac
he.felix.ipojo;version= 1.6.0, org.osgi.service.cm;version=1.2
Bundle-SymbolicName: com.packtpub.felix.bookshelf-service
Bookshelf Service Gogo commands 1.9.0
Manifest-Version: 1.0
Export-Package: com.packtpub.felix.bookshelf.service.tui;uses:="com.pa
cktpub.felix.bookshelf.inventory.api,com.packtpub.felix.bookshelf.ser
vice.api,org.apache.felix.service.command"
iPOJO-Components: instance { $component="BookshelfServiceProxy" $name=
"bookshelf.service.tui" }component { $name="BookshelfServiceProxy" $c
lassname="com.packtpub.felix.bookshelf.service.tui.BookshelfServicePr
oxyImpl" $public="true" provides { property { $field="gogoScope" $nam
e="osgi.command.scope" $value="book" }property { $field="gogoFunction
s" $name="osgi.command.function" $value="[add,search]" }}manipulation
{ field { $name="bookshelf" $type="com.packtpub.felix.bookshelf.serv
ice.api.BookshelfService" }field { $name="gogoScope" $type="java.lang
.String" }field { $name="gogoFunctions" $type="java.lang.String[]" }m
ethod { $name="$init" }method { $name="lookupService" $return="com.pa
cktpub.felix.bookshelf.service.api.BookshelfService" }method { $argum
ents="{java.lang.String,java.lang.String,java.lang.String,java.lang.S
tring,java.lang.String,java.lang.String,int}" $name="add" $return="ja
va.lang.String" }method { $arguments="{java.lang.String,java.lang.Str
ing,java.lang.String,java.lang.String}" $name="search" $return="java.
util.Set" }method { $arguments="{java.lang.String,java.lang.String,ja
va.lang.String,int,int}" $name="search" $return="java.util.Set" }meth
od { $arguments="{java.lang.String,com.packtpub.felix.bookshelf.servi
ce.api.BookshelfService,java.util.Set}" $name="getBooks" $return="jav
a.util.Set" }interface { $name="com.packtpub.felix.bookshelf.service.
tui.BookshelfServiceProxy" }}requires { $field="bookshelf" }}
Built-By: awalker
Tool: Bnd-0.0.357
Bundle-Category: sample
Bundle-Name: Bookshelf Service Gogo commands
Created-By: Apache Maven Bundle Plugin & iPOJO 1.6.0
Build-Jdk: 1.6.0_24
Bundle-Version: 1.9.0
Bnd-LastModified: 1305650360964
Bundle-ManifestVersion: 2
Bundle-Description: The text user-interface
Import-Package: com.packtpub.felix.bookshelf.inventory.api, org.osgi.s
ervice.log;version=1.3, org.apache.felix.service.command;status=provi
sional;version=0.8, com.packtpub.felix.bookshelf.service.api, org.apa
che.felix.ipojo.architecture;version= 1.6.0, org.apache.felix.ipojo;v
ersion= 1.6.0, org.osgi.service.cm;version=1.2, com.packtpub.felix.bo
okshelf.service.tui
Bundle-SymbolicName: com.packtpub.felix.bookshelf-service-tui
Upvotes: 2
Views: 224
Reputation: 66
Ok, this is years late, but I just ran into almost the same problem, following along the same book. It turned out the issue was that I'd broken the Export-Package commands in the pom.xml for the original Bookshelf Service bundle in going from the 1.7.0 to 1.10.0 versions. Check things carefully - what the 'instance' command says about the problems with the installed bundles that aren't running, what the manifest files say, what's in pom.xml, etc.
Upvotes: 2