You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by XiLai Dai <xl...@talend.com> on 2015/04/14 11:44:24 UTC

ClassCastException, cannot be cast to org.apache.felix.gogo.commands.Action

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

Re: ClassCastException, cannot be cast to org.apache.felix.gogo.commands.Action

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Xilai,

oh, correct, let me check if FeaturesCommandSupport is still valid.

Regards
JB

On 04/15/2015 11:21 AM, XiLai Dai wrote:
> 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:jb@nanthrax.net]
> Sent: Tuesday, April 14, 2015 5:56 PM
> To: user@karaf.apache.org
> 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é
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

RE: ClassCastException, cannot be cast to org.apache.felix.gogo.commands.Action

Posted by XiLai Dai <xl...@talend.com>.
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:jb@nanthrax.net] 
Sent: Tuesday, April 14, 2015 5:56 PM
To: user@karaf.apache.org
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: ClassCastException, cannot be cast to org.apache.felix.gogo.commands.Action

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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é
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com