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

Dependencies 部署时所需的资源与pom中的说明不匹配,dependencies,osgi,apache-felix,Dependencies,Osgi,Apache Felix,我正在浏览这本书“”,遇到了一个问题,我正在部署的包坚持认为它依赖于另一个包的错误版本。对于以前研究过这些示例的人,我只在第10章的末尾—在Bookshelf Service Bundle中实现日志记录功能 基本上,问题如下: deploy -s "Bookshelf Service Gogo commands" Target resource(s): ------------------- Bookshelf Service Gogo commands (1.9.0) Required r

我正在浏览这本书“”,遇到了一个问题,我正在部署的包坚持认为它依赖于另一个包的错误版本。对于以前研究过这些示例的人,我只在第10章的末尾—在Bookshelf Service Bundle中实现日志记录功能

基本上,问题如下:

deploy -s "Bookshelf Service Gogo commands"

Target resource(s):
-------------------
Bookshelf Service Gogo commands (1.9.0)

Required resource(s):
---------------------
Bookshelf Service (1.7.0)
<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>
我有一个名为“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 commands”的包,它是“Bookshelf Service”中功能的命令行界面。它的版本是1.9.0

令人费解的是,当我部署“Bookshelf Service Gogo commands”捆绑包时,它的安装如下所示:

deploy -s "Bookshelf Service Gogo commands"

Target resource(s):
-------------------
Bookshelf Service Gogo commands (1.9.0)

Required resource(s):
---------------------
Bookshelf Service (1.7.0)
<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.10.0版

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

但是,根据pom.xml文件,依赖关系确实适用于1.10.0版本的“Bookshelf Service”。“书架服务Gogo命令”的POM如下:

deploy -s "Bookshelf Service Gogo commands"

Target resource(s):
-------------------
Bookshelf Service Gogo commands (1.9.0)

Required resource(s):
---------------------
Bookshelf Service (1.7.0)
<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.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中原始Bookshelf服务包的导出包命令。仔细检查-instance命令如何说明未运行的已安装捆绑包的问题,manifest文件如何说明,pom.xml中有什么内容,等等。

我有一种感觉(要确认这一点,请尝试在控制台中键入
refresh
,稍后我将提供详细答案),但是,请您将您正在谈论的三个捆绑包的生成清单包括在内,好吗?我键入了refresh,收到了“欢迎使用Apache Felix”消息-然后,当我使用命令lb查看更改时,出现了一个错误,指出了一个非法状态异常和一个无效的BundleContext。从清单判断,它看起来比我想象的要平凡一些:我最好的猜测是,您的捆绑包有一些未满足的服务依赖项,例如config admin的日志服务。否则,我就不知所措了,因为我还没有读过这本书,很难通过交换意见来准确判断您的系统发生了什么。很公平,谢谢您的关注。