部署时所需资源与pom中的指令不匹配

时间:2011-05-17 19:37:00

标签: dependencies osgi apache-felix

我正在阅读“OSGi and Apache Felix 3.0”这本书并遇到了一个问题,即我正在部署的软件包坚持认为它依赖于另一个软件包的错误版本。对于之前已经完成这些示例的任何人,我只是在第10章的末尾 - 在Bookshelf Service Bundle中实现日志记录功能。

基本上问题如下:

我有一个名为“Bookshelf Service”的软件包,我刚刚添加了一些新的日志记录功能。此新功能将其置于版本1.10.0

我有另一个名为“Bookshelf Service Gogo commands”的软件包,它是“Bookshelf Service”中功能的命令行界面。它的版本是1.9.0。

令人费解的是,当我部署“Bookshelf Service 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)

“Bookshelf Service”套装当然是错误的版本。我想使用版本1.10.0。

如果我更新或强制框架使用版本1.10.0,那么“Bookshelf Service Gogo命令”提供的功能将不再可用。它拒绝使用最新版本的“Bookshelf Service”。

根据pom.xml文件,依赖性确实适用于1.10.0版本的“Bookshelf Service”。 “Bookshelf Service 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文件。我不认为问题存在,因为我一直在将我的代码与书籍示例的可下载示例代码进行比较,而且一切似乎都匹配。

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


编辑:

根据要求,生成的清单。

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版本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命令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 个答案:

答案 0 :(得分:2)

好的,这已经晚了很多年,但我遇到了几乎同样的问题,跟着同一本书。事实证明,问题在于我打破了原始Bookshelf Service捆绑包的pom.xml中的Export-Package命令,从1.7.0到1.10.0版本。仔细检查一下 - &#39;实例&#39;命令说明已安装的未运行的软件包的问题,​​清单文件的内容,pom.xml中的内容等等。