Dependency Manager commands not working after upgrading Servicemix from 5.4.0 to 6.1.2

211 views Asked by At

We have an application deployed in Servicemix 5.4.0 (http://servicemix.apache.org/downloads/servicemix-5.4.0.html) and recently tried upgrading to Servicemix 6.1.2 (http://servicemix.apache.org/downloads/servicemix-6.1.2.html). One thing we rely on is the Felix Dependency Manager and in particular the 'dm wtf' command (see http://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/tutorials/leveraging-the-shell.html ) . However after tried our code with the later Servicemix we get this :-

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

The versions concerned (when we run list) are :-

 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

Has anyone tried to get Felix working with Servicemix 6.1.2? Does anyone have any ideas on what we could try to get this command (or equivalent) to work? Apparently Apache Felix that was downgraded from 4.4.1 to 4.2.1 but Karaf was upgraded from 2.4.1 to 3.0.7 so not sure if we needed to modify our feature config :-

<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

There are 1 answers

1
mikeclark On

I've been debugging this and have found that the issue is due to the parameter annotation on method DMCommand.dm(). The parameters to this method are the names of the options available in the dm command (wtf, stats, nodeps etc) and the annotations on these parameters define how these options should be mapped in the DMCommand object (i.e. if 'wtf' is present it should set the value of a boolean to true, but if it is not there the boolean should be false).

During the execution of the dm wtf command in the ServiceMix console, org.apache.felix.gogo.runtime.Reflective.transformParameters() uses these annotations, by calling java.lang.reflect.method.getParameterAnnotations(), to convert the option values in the command string to an array of the correct value types and values (i.e. converts the string 'wtf' to true).

The problem in ServiceMix 6.1.2 is that the call to java.lang.reflect.method.getParameterAnnotations() returns an array of empty java.lang.annotation.Annotation objects. This means no conversion occurs in org.apache.felix.gogo.runtime.Reflective.transformParameters(), resulting in incorrect parameter types and values (the 'wtf' option remains as a String, instead of changing to a boolean), which means we see the exception;

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

Based on what I've seen/found so far, I don't see how you are going to be able to do anything to resolve this yourdelf. I've tested this on ServiceMix 5.4.0 and 6.1.2, using the same JDK (1.7.0_79), so it appears to be an issue with the change in Karaf and Felix versions.