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.createNewAction(BlueprintCommand.java:100)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.commands.basic.AbstractCommand.getActionClass(AbstractCommand.java:44)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.compat.ArgumentCompleter.<init>(ArgumentCompleter.java:86)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.compat.CommandTracker$1.getCompleter(CommandTracker.java:91)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.impl.console.CommandsCompleter.checkData(CommandsCompleter.java:212)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.impl.console.CommandsCompleter.complete(CommandsCompleter.java:63)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.impl.console.CompleterAsCompletor.complete(CompleterAsCompletor.java:41)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
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.readAndParseCommand(ConsoleSessionImpl.java:366)[50:org.apache.karaf.shell.core:4.0.0.SNAPSHOT]
at
org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.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