将Servicemix从5.4.0升级到6.1.2后,Dependency Manager命令无法正常工作

时间:2017-01-09 15:14:31

标签: apache-felix apache-servicemix

我们在Servicemix 5.4.0(http://servicemix.apache.org/downloads/servicemix-5.4.0.html)中部署了一个应用程序,最近尝试升级到Servicemix 6.1.2(http://servicemix.apache.org/downloads/servicemix-6.1.2.html)。我们依赖的一件事是Felix Dependency Manager,特别是'dm wtf'命令(参见http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/tutorials/leveraging-the-shell.html)。但是在尝试使用后面的Servicemix我们的代码后,我们得到了这个: -

karaf@root>dm wtf
Error executing command: Cannot coerce dm(String) to any of [(CommandSession, boolean, String, boolean, boolean, boolean, String, String, String, String)]

相关版本(当我们运行列表时)是: -

 76 | Active |  80 | 1.0.10                             | Apache Felix MetatypeService
 77 | Active |  80 | 3.2.0                              | Apache Felix Dependency Manager
 78 | Active |  80 | 3.2.0                              | Apache Felix Dependency Manager Shell

有没有人试图让Felix使用Servicemix 6.1.2? 有没有人对我们可以尝试使这个命令(或等效的)工作有任何想法?显然Apache Felix从4.4.1降级到4.2.1但Karaf从2.4.1升级到3.0.7所以不确定我们是否需要修改我们的功能配置: -

<feature name="example-feature" version="X.X.X">
                <bundle>mvn:org.apache.felix/org.apache.felix.metatype/1.0.10</bundle>
                <bundle>mvn:org.apache.felix/org.apache.felix.dependencymanager/3.2.0</bundle>
                <bundle>mvn:org.apache.felix/org.apache.felix.dependencymanager.shell/3.2.0</bundle>
</feature>

1 个答案:

答案 0 :(得分:1)

我一直在调试这个,并且发现问题是由方法DMCommand.dm()上的参数注释引起的。此方法的参数是dm命令中可用选项的名称(wtf,stats,nodeps等),这些参数的注释定义了如何在DMCommand对象中映射这些选项(即,如果'wtf'存在,它应该将布尔值设置为true,但如果不存在则布尔值应为false)。

在ServiceMix控制台中执行dm wtf命令期间,org.apache.felix.gogo.runtime.Reflective.transformParameters()使用这些注释,通过调用java.lang.reflect.method.getParameterAnnotations()来实现将命令字符串中的选项值转换为正确值类型和值的数组(即将字符串'wtf'转换为true)。

ServiceMix 6.1.2中的问题是对java.lang.reflect.method.getParameterAnnotations()的调用返回一个空java.lang.annotation.Annotation对象的数组。这意味着org.apache.felix.gogo.runtime.Reflective.transformParameters()中没有转换,导致参数类型和值不正确('wtf'选项保留为String,而不是更改为布尔值),这意味着我们看到例外;

Cannot coerce dm(String) to any of [(CommandSession, boolean, String, boolean, boolean, boolean, String, String, String, String)]

根据我到目前为止看到/发现的内容,我不知道你将如何能够做任何事来解决这个问题。我在ServiceMix 5.4.0和6.1.2上使用相同的JDK(1.7.0_79)对此进行了测试,因此它似乎是Karaf和Felix版本更改的问题。

相关问题