Hi, JB, There is no any custom completer for those commands. The interesting is the commands will work if let it extends OsgiCommandSupport instead of FeaturesCommandSupport.
Thanks. Xilai -----Original Message----- From: Jean-Baptiste Onofré [mailto:[email protected]] Sent: Tuesday, April 14, 2015 5:56 PM To: [email protected] Subject: Re: ClassCastException, cannot be cast to org.apache.felix.gogo.commands.Action Hi Xilai, the command annotations now comes from org.apache.karaf package. It was already deprecated in K3 but still working. Did you upgrade the completers as well ? regards JB On 04/14/2015 11:44 AM, XiLai Dai wrote: > Hi, > > The custom console commands we developed on karaf 2.x don't work > anymore on the karaf 4.0 > > The code used on 2.x: > > import org.apache.felix.gogo.commands.Command; > > import org.apache.karaf.features.command.FeaturesCommandSupport; > > @Command(scope = "test", name = "switch-abc", description = "test > command") > > public class TestComand extends FeaturesCommandSupport { > > .. > > } > > The code used on 4.0 (make changes following 4.0 api): > > import org.apache.karaf.features.command.FeaturesCommandSupport; > > import org.apache.karaf.shell.api.action.Command; > > import org.apache.karaf.shell.api.action.lifecycle.Service; > > @Command(scope = "test", name = "switch-abc", description = "test > command") > > @Service > > public class TestComand extends FeaturesCommandSupport { > > .. > > } > > After install this command bundle into karaf 4, the ClassCastException > will be thrown: > > 16:56:11,330 | ERROR | nsole user karaf | > he.karaf.shell.support.ShellUtil 149 | 50 - > org.apache.karaf.shell.core > - 4.0.0.SNAPSHOT | Exception caught while executing command > > java.lang.ClassCastException: org.abc.TestComand cannot be cast to > org.apache.felix.gogo.commands.Action > > at > org.apache.karaf.shell.console.commands.BlueprintCommand.createNewActi > on(BlueprintCommand.java:100)[50:org.apache.karaf.shell.core:4.0.0.SNA > PSHOT] > > at > org.apache.karaf.shell.commands.basic.AbstractCommand.getActionClass(A > bstractCommand.java:44)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at > org.apache.karaf.shell.compat.ArgumentCompleter.<init>(ArgumentComplet > er.java:86)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at > org.apache.karaf.shell.compat.CommandTracker$1.getCompleter(CommandTra > cker.java:91)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at > org.apache.karaf.shell.impl.console.CommandsCompleter.checkData(Comman > dsCompleter.java:212)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at > org.apache.karaf.shell.impl.console.CommandsCompleter.complete(Command > sCompleter.java:63)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at > org.apache.karaf.shell.impl.console.CompleterAsCompletor.complete(Comp > leterAsCompletor.java:41)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHO > T] > > at > jline.console.ConsoleReader.complete(ConsoleReader.java:3261)[12:jline > :2.12.1] > > at > jline.console.ConsoleReader.readLine(ConsoleReader.java:2621)[12:jline > :2.12.1] > > at > jline.console.ConsoleReader.readLine(ConsoleReader.java:2269)[12:jline > :2.12.1] > > at > org.apache.karaf.shell.impl.console.ConsoleSessionImpl.readAndParseCom > mand(ConsoleSessionImpl.java:366)[50:org.apache.karaf.shell.core:4.0.0 > .SNAPSHOT] > > at > org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSess > ionImpl.java:262)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT] > > at java.lang.Thread.run(Thread.java:744)[:1.7.0_51] > > any idea/suggestion about this? > > Thanks. > > Xilai Dai > -- Jean-Baptiste Onofré [email protected] http://blog.nanthrax.net Talend - http://www.talend.com
