部署时所需的资源与 POM 中的说明不匹配



我正在浏览"OSGi和Apache Felix 3.0"一书,遇到了一个问题,即我正在部署的捆绑包坚持认为它依赖于另一个捆绑包的错误版本。对于以前处理过这些示例的任何人,我刚刚结束了第 10 章 - 在书架服务包中实现日志记录功能。

基本上问题如下:

有一个名为"书架服务"的捆绑包,我刚刚在其中添加了一些甜蜜的新日志记录功能。此新功能将其置于版本 1.10.0

我还有另一个叫做"书架服务Gogo命令"的捆绑包,它是"书架服务"中功能的命令行界面。它的版本为 1.9.0。

令人费解的是,当我部署"书架服务 Gogo 命令"捆绑包时,它的安装方式如下:

deploy -s "Bookshelf Service Gogo commands"
Target resource(s):
-------------------
Bookshelf Service Gogo commands (1.9.0)
Required resource(s):
---------------------
Bookshelf Service (1.7.0)

这当然是"书架服务"捆绑包的错误版本。我想使用 1.10.0 版。

如果我更新或强制框架使用版本 1.10.0,则"书架服务 Gogo 命令"提供的功能将不再可用。它拒绝使用最新版本的"书架服务"。

不过,根据pom.xml文件,该依赖项确实适用于1.10.0版本的"书架服务"。"书架服务 Gogo 命令"的 POM 如下所示:

<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>

所以我不明白为什么它只想使用 1.7.0。

还值得一提的是,这两个捆绑包都利用了 iPOJO,因此它们确实有 meta.xml 文件。但是,我认为问题不在那里,因为我一直在将我的代码与书籍示例的可下载示例代码进行比较,并且一切似乎都匹配。

关于出了什么问题,或者在哪里寻找这个问题的根源的任何想法?


编辑:

根据请求,生成的清单。

书架服务 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"

书架服务版本 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

书架服务 Gogo 命令 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

好吧,这已经晚了好几年了,但我只是遇到了几乎相同的问题,按照同一本书。事实证明,问题是我在从 1.7.0 到 1.10.0 版本中破坏了原始书架服务捆绑包的 pom 中的导出包命令.xml。仔细检查 - "instance"命令说明了未运行的已安装捆绑包的问题,清单文件的内容,pom.xml中的内容等。

最新更新