You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@karaf.apache.org by Charles Moulliard <ch...@gmail.com> on 2013/11/29 10:18:14 UTC

NPE with command Help & Karaf Shell Console

Hi,

For a documentation project, I'm currently creating a Java Command Line
Tool client using our excellent Apache Karaf Shell Console. Nevertheless,
when I try to get help from a command, Gogo & Felix returns a NPE

HylaMain
java.io.BufferedInputStream@9506dc4
hyla>echo blabla
echo blabla
blabla
hyla>help echo
help echo
[main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
caught while executing command
java.lang.NullPointerException
at
org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)
at
org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)
at
org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
at org.apache.karaf.shell.console.Main.run(Main.java:220)
at org.apache.karaf.shell.console.Main.run(Main.java:164)
at org.apache.karaf.shell.console.Main.run(Main.java:79)
at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Error executing command: java.lang.NullPointerException

As this code is really hard to debug as we have embedded the code of
org.apache.felix.gogo.runtime
& org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
anybody knows why I could get a NPE when we call this method. In debug
mode, I confirm that the session object exists but the command is null
(even if I'm able to recuperate the args 'help echo' and this command works
'echo blabla'

Regards,

-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: NPE with command Help & Karaf Shell Console

Posted by Charles Moulliard <ch...@gmail.com>.
Thx. I just discover that with the HelpSystem class

public class HelpSystem implements HelpProvider {

    private BundleContext context;


On Fri, Nov 29, 2013 at 11:08 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> In that case, HelpAction won't work: HelpAction is looking for
> HelpProvider OSGi service ;)
>
> That's why you got NPE.
>
> Regards
> JB
>
>
> On 11/29/2013 10:59 AM, Charles Moulliard wrote:
>
>> I'm running the Karaf Shell Console without OSGI ;-) but just as a simple
>> CLI (java -CP HylaMain) like we have done also for Scalate
>> (
>> https://github.com/scalate/scalate/blob/scala_2.10/
>> scalate-tool/src/main/scala/org/fusesource/scalate/tool/ScalateMain.scala
>> )
>>
>>
>> On Fri, Nov 29, 2013 at 10:48 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>> >wrote:
>>
>>  Instead of extending HelpAction (HelpAction requires additional
>>> attributes/methods to override), I would try to extends
>>> org.apache.karaf.shell.console.OsgiCommandSupport and define the
>>> blueprint:
>>>
>>> @Command(scope = "hyla", name = "help", description = "Display this
>>> help")
>>> public class MyHelp extends OsgiCommandSupport {
>>>
>>>    public Object doExecute() throws Exception {
>>>       return null;
>>>    }
>>>
>>> }
>>>
>>> and in the associated blueprint:
>>>
>>> <command name="hyla/help">
>>>    <action class="MyHelp"/>
>>> </command>
>>>
>>> Regards
>>> JB
>>>
>>>
>>> On 11/29/2013 10:40 AM, Charles Moulliard wrote:
>>>
>>>  Yep. If required, I can provide a small project.
>>>>
>>>> @Command(scope = "hyla", name = "help", description = "Displays this
>>>> help
>>>> or help about a command")
>>>> public class Help extends HelpAction {
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> On Fri, Nov 29, 2013 at 10:38 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>>   Hi Charles,
>>>>
>>>>>
>>>>> do you have description attribute on the @Command annotation ?
>>>>>
>>>>> Regards
>>>>> JB
>>>>>
>>>>>
>>>>> On 11/29/2013 10:32 AM, Charles Moulliard wrote:
>>>>>
>>>>>   2.3.3
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <
>>>>>> jb@nanthrax.net
>>>>>>
>>>>>>  wrote:
>>>>>>>
>>>>>>>
>>>>>>    Hi Charles,
>>>>>>
>>>>>>
>>>>>>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>>>>>>
>>>>>>> Regards
>>>>>>> JB
>>>>>>>
>>>>>>>
>>>>>>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>>>>>>
>>>>>>>    Hi,
>>>>>>>
>>>>>>>
>>>>>>>> For a documentation project, I'm currently creating a Java Command
>>>>>>>> Line
>>>>>>>> Tool client using our excellent Apache Karaf Shell Console.
>>>>>>>> Nevertheless,
>>>>>>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>>>>>>
>>>>>>>> HylaMain
>>>>>>>> java.io.BufferedInputStream@9506dc4
>>>>>>>> hyla>echo blabla
>>>>>>>> echo blabla
>>>>>>>> blabla
>>>>>>>> hyla>help echo
>>>>>>>> help echo
>>>>>>>> [main] ERROR org.apache.karaf.shell.console.jline.Console -
>>>>>>>> Exception
>>>>>>>> caught while executing command
>>>>>>>> java.lang.NullPointerException
>>>>>>>> at
>>>>>>>> org.apache.karaf.shell.console.help.HelpAction.
>>>>>>>> doExecute(HelpAction.java:40)
>>>>>>>> at
>>>>>>>> org.apache.karaf.shell.console.AbstractAction.
>>>>>>>> execute(AbstractAction.java:33)
>>>>>>>> at
>>>>>>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>>>>>>> AbstractCommand.java:35)
>>>>>>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.
>>>>>>>> java:474)
>>>>>>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>>>>>>> Closure.java:400)
>>>>>>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>>>>>>> at
>>>>>>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>>>>>>> CommandSessionImpl.java:89)
>>>>>>>> at org.apache.karaf.shell.console.jline.Console.run(
>>>>>>>> Console.java:173)
>>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>>>>>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>> at
>>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>>>>>> NativeMethodAccessorImpl.java:39)
>>>>>>>> at
>>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>>>>>> DelegatingMethodAccessorImpl.java:25)
>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>>> at com.intellij.rt.execution.application.AppMain.main(
>>>>>>>> AppMain.java:120)
>>>>>>>> Error executing command: java.lang.NullPointerException
>>>>>>>>
>>>>>>>> As this code is really hard to debug as we have embedded the code of
>>>>>>>> org.apache.felix.gogo.runtime
>>>>>>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console,
>>>>>>>> does
>>>>>>>> anybody knows why I could get a NPE when we call this method. In
>>>>>>>> debug
>>>>>>>> mode, I confirm that the session object exists but the command is
>>>>>>>> null
>>>>>>>> (even if I'm able to recuperate the args 'help echo' and this
>>>>>>>> command
>>>>>>>> works
>>>>>>>> 'echo blabla'
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>>
>>>>>>>>    --
>>>>>>>>
>>>>>>>>  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
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>  --
>>> 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
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: NPE with command Help & Karaf Shell Console

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
In that case, HelpAction won't work: HelpAction is looking for 
HelpProvider OSGi service ;)

That's why you got NPE.

Regards
JB

On 11/29/2013 10:59 AM, Charles Moulliard wrote:
> I'm running the Karaf Shell Console without OSGI ;-) but just as a simple
> CLI (java -CP HylaMain) like we have done also for Scalate
> (
> https://github.com/scalate/scalate/blob/scala_2.10/scalate-tool/src/main/scala/org/fusesource/scalate/tool/ScalateMain.scala
> )
>
>
> On Fri, Nov 29, 2013 at 10:48 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:
>
>> Instead of extending HelpAction (HelpAction requires additional
>> attributes/methods to override), I would try to extends
>> org.apache.karaf.shell.console.OsgiCommandSupport and define the
>> blueprint:
>>
>> @Command(scope = "hyla", name = "help", description = "Display this help")
>> public class MyHelp extends OsgiCommandSupport {
>>
>>    public Object doExecute() throws Exception {
>>       return null;
>>    }
>>
>> }
>>
>> and in the associated blueprint:
>>
>> <command name="hyla/help">
>>    <action class="MyHelp"/>
>> </command>
>>
>> Regards
>> JB
>>
>>
>> On 11/29/2013 10:40 AM, Charles Moulliard wrote:
>>
>>> Yep. If required, I can provide a small project.
>>>
>>> @Command(scope = "hyla", name = "help", description = "Displays this help
>>> or help about a command")
>>> public class Help extends HelpAction {
>>>
>>> }
>>>
>>>
>>>
>>> On Fri, Nov 29, 2013 at 10:38 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>>>> wrote:
>>>
>>>   Hi Charles,
>>>>
>>>> do you have description attribute on the @Command annotation ?
>>>>
>>>> Regards
>>>> JB
>>>>
>>>>
>>>> On 11/29/2013 10:32 AM, Charles Moulliard wrote:
>>>>
>>>>   2.3.3
>>>>>
>>>>>
>>>>> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>
>>>>>    Hi Charles,
>>>>>
>>>>>>
>>>>>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>>>>>
>>>>>> Regards
>>>>>> JB
>>>>>>
>>>>>>
>>>>>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>>>>>
>>>>>>    Hi,
>>>>>>
>>>>>>>
>>>>>>> For a documentation project, I'm currently creating a Java Command
>>>>>>> Line
>>>>>>> Tool client using our excellent Apache Karaf Shell Console.
>>>>>>> Nevertheless,
>>>>>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>>>>>
>>>>>>> HylaMain
>>>>>>> java.io.BufferedInputStream@9506dc4
>>>>>>> hyla>echo blabla
>>>>>>> echo blabla
>>>>>>> blabla
>>>>>>> hyla>help echo
>>>>>>> help echo
>>>>>>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>>>>>>> caught while executing command
>>>>>>> java.lang.NullPointerException
>>>>>>> at
>>>>>>> org.apache.karaf.shell.console.help.HelpAction.
>>>>>>> doExecute(HelpAction.java:40)
>>>>>>> at
>>>>>>> org.apache.karaf.shell.console.AbstractAction.
>>>>>>> execute(AbstractAction.java:33)
>>>>>>> at
>>>>>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>>>>>> AbstractCommand.java:35)
>>>>>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>>>>>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>>>>>> Closure.java:400)
>>>>>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>>>>>> at
>>>>>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>>>>>> CommandSessionImpl.java:89)
>>>>>>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>>>>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>> at
>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>>>>> NativeMethodAccessorImpl.java:39)
>>>>>>> at
>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>>>>> DelegatingMethodAccessorImpl.java:25)
>>>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>> at com.intellij.rt.execution.application.AppMain.main(
>>>>>>> AppMain.java:120)
>>>>>>> Error executing command: java.lang.NullPointerException
>>>>>>>
>>>>>>> As this code is really hard to debug as we have embedded the code of
>>>>>>> org.apache.felix.gogo.runtime
>>>>>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console,
>>>>>>> does
>>>>>>> anybody knows why I could get a NPE when we call this method. In debug
>>>>>>> mode, I confirm that the session object exists but the command is null
>>>>>>> (even if I'm able to recuperate the args 'help echo' and this command
>>>>>>> works
>>>>>>> 'echo blabla'
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>>
>>>>>>>    --
>>>>>>>
>>>>>> 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
>>>>
>>>>
>>>
>>>
>>>
>> --
>> 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: NPE with command Help & Karaf Shell Console

Posted by Charles Moulliard <ch...@gmail.com>.
I'm running the Karaf Shell Console without OSGI ;-) but just as a simple
CLI (java -CP HylaMain) like we have done also for Scalate
(
https://github.com/scalate/scalate/blob/scala_2.10/scalate-tool/src/main/scala/org/fusesource/scalate/tool/ScalateMain.scala
)


On Fri, Nov 29, 2013 at 10:48 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Instead of extending HelpAction (HelpAction requires additional
> attributes/methods to override), I would try to extends
> org.apache.karaf.shell.console.OsgiCommandSupport and define the
> blueprint:
>
> @Command(scope = "hyla", name = "help", description = "Display this help")
> public class MyHelp extends OsgiCommandSupport {
>
>   public Object doExecute() throws Exception {
>      return null;
>   }
>
> }
>
> and in the associated blueprint:
>
> <command name="hyla/help">
>   <action class="MyHelp"/>
> </command>
>
> Regards
> JB
>
>
> On 11/29/2013 10:40 AM, Charles Moulliard wrote:
>
>> Yep. If required, I can provide a small project.
>>
>> @Command(scope = "hyla", name = "help", description = "Displays this help
>> or help about a command")
>> public class Help extends HelpAction {
>>
>> }
>>
>>
>>
>> On Fri, Nov 29, 2013 at 10:38 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>> >wrote:
>>
>>  Hi Charles,
>>>
>>> do you have description attribute on the @Command annotation ?
>>>
>>> Regards
>>> JB
>>>
>>>
>>> On 11/29/2013 10:32 AM, Charles Moulliard wrote:
>>>
>>>  2.3.3
>>>>
>>>>
>>>> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>>   Hi Charles,
>>>>
>>>>>
>>>>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>>>>
>>>>> Regards
>>>>> JB
>>>>>
>>>>>
>>>>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>>>>
>>>>>   Hi,
>>>>>
>>>>>>
>>>>>> For a documentation project, I'm currently creating a Java Command
>>>>>> Line
>>>>>> Tool client using our excellent Apache Karaf Shell Console.
>>>>>> Nevertheless,
>>>>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>>>>
>>>>>> HylaMain
>>>>>> java.io.BufferedInputStream@9506dc4
>>>>>> hyla>echo blabla
>>>>>> echo blabla
>>>>>> blabla
>>>>>> hyla>help echo
>>>>>> help echo
>>>>>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>>>>>> caught while executing command
>>>>>> java.lang.NullPointerException
>>>>>> at
>>>>>> org.apache.karaf.shell.console.help.HelpAction.
>>>>>> doExecute(HelpAction.java:40)
>>>>>> at
>>>>>> org.apache.karaf.shell.console.AbstractAction.
>>>>>> execute(AbstractAction.java:33)
>>>>>> at
>>>>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>>>>> AbstractCommand.java:35)
>>>>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>>>>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>>>>> Closure.java:400)
>>>>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>>>>> at
>>>>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>>>>> CommandSessionImpl.java:89)
>>>>>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>>>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>> at
>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>>>> NativeMethodAccessorImpl.java:39)
>>>>>> at
>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>>>> DelegatingMethodAccessorImpl.java:25)
>>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>> at com.intellij.rt.execution.application.AppMain.main(
>>>>>> AppMain.java:120)
>>>>>> Error executing command: java.lang.NullPointerException
>>>>>>
>>>>>> As this code is really hard to debug as we have embedded the code of
>>>>>> org.apache.felix.gogo.runtime
>>>>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console,
>>>>>> does
>>>>>> anybody knows why I could get a NPE when we call this method. In debug
>>>>>> mode, I confirm that the session object exists but the command is null
>>>>>> (even if I'm able to recuperate the args 'help echo' and this command
>>>>>> works
>>>>>> 'echo blabla'
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>>
>>>>>>   --
>>>>>>
>>>>> 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
>>>
>>>
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: NPE with command Help & Karaf Shell Console

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Instead of extending HelpAction (HelpAction requires additional 
attributes/methods to override), I would try to extends 
org.apache.karaf.shell.console.OsgiCommandSupport and define the blueprint:

@Command(scope = "hyla", name = "help", description = "Display this help")
public class MyHelp extends OsgiCommandSupport {

   public Object doExecute() throws Exception {
      return null;
   }

}

and in the associated blueprint:

<command name="hyla/help">
   <action class="MyHelp"/>
</command>

Regards
JB

On 11/29/2013 10:40 AM, Charles Moulliard wrote:
> Yep. If required, I can provide a small project.
>
> @Command(scope = "hyla", name = "help", description = "Displays this help
> or help about a command")
> public class Help extends HelpAction {
>
> }
>
>
>
> On Fri, Nov 29, 2013 at 10:38 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:
>
>> Hi Charles,
>>
>> do you have description attribute on the @Command annotation ?
>>
>> Regards
>> JB
>>
>>
>> On 11/29/2013 10:32 AM, Charles Moulliard wrote:
>>
>>> 2.3.3
>>>
>>>
>>> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>>>> wrote:
>>>
>>>   Hi Charles,
>>>>
>>>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>>>
>>>> Regards
>>>> JB
>>>>
>>>>
>>>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>>>
>>>>   Hi,
>>>>>
>>>>> For a documentation project, I'm currently creating a Java Command Line
>>>>> Tool client using our excellent Apache Karaf Shell Console.
>>>>> Nevertheless,
>>>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>>>
>>>>> HylaMain
>>>>> java.io.BufferedInputStream@9506dc4
>>>>> hyla>echo blabla
>>>>> echo blabla
>>>>> blabla
>>>>> hyla>help echo
>>>>> help echo
>>>>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>>>>> caught while executing command
>>>>> java.lang.NullPointerException
>>>>> at
>>>>> org.apache.karaf.shell.console.help.HelpAction.
>>>>> doExecute(HelpAction.java:40)
>>>>> at
>>>>> org.apache.karaf.shell.console.AbstractAction.
>>>>> execute(AbstractAction.java:33)
>>>>> at
>>>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>>>> AbstractCommand.java:35)
>>>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>>>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>>>> Closure.java:400)
>>>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>>>> at
>>>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>>>> CommandSessionImpl.java:89)
>>>>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>> at
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>>> NativeMethodAccessorImpl.java:39)
>>>>> at
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>>> DelegatingMethodAccessorImpl.java:25)
>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>>>>> Error executing command: java.lang.NullPointerException
>>>>>
>>>>> As this code is really hard to debug as we have embedded the code of
>>>>> org.apache.felix.gogo.runtime
>>>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
>>>>> anybody knows why I could get a NPE when we call this method. In debug
>>>>> mode, I confirm that the session object exists but the command is null
>>>>> (even if I'm able to recuperate the args 'help echo' and this command
>>>>> works
>>>>> 'echo blabla'
>>>>>
>>>>> Regards,
>>>>>
>>>>>
>>>>>   --
>>>> 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
>>
>
>
>

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

Re: NPE with command Help & Karaf Shell Console

Posted by Charles Moulliard <ch...@gmail.com>.
Yep. If required, I can provide a small project.

@Command(scope = "hyla", name = "help", description = "Displays this help
or help about a command")
public class Help extends HelpAction {

}



On Fri, Nov 29, 2013 at 10:38 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Charles,
>
> do you have description attribute on the @Command annotation ?
>
> Regards
> JB
>
>
> On 11/29/2013 10:32 AM, Charles Moulliard wrote:
>
>> 2.3.3
>>
>>
>> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb@nanthrax.net
>> >wrote:
>>
>>  Hi Charles,
>>>
>>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>>
>>> Regards
>>> JB
>>>
>>>
>>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>>
>>>  Hi,
>>>>
>>>> For a documentation project, I'm currently creating a Java Command Line
>>>> Tool client using our excellent Apache Karaf Shell Console.
>>>> Nevertheless,
>>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>>
>>>> HylaMain
>>>> java.io.BufferedInputStream@9506dc4
>>>> hyla>echo blabla
>>>> echo blabla
>>>> blabla
>>>> hyla>help echo
>>>> help echo
>>>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>>>> caught while executing command
>>>> java.lang.NullPointerException
>>>> at
>>>> org.apache.karaf.shell.console.help.HelpAction.
>>>> doExecute(HelpAction.java:40)
>>>> at
>>>> org.apache.karaf.shell.console.AbstractAction.
>>>> execute(AbstractAction.java:33)
>>>> at
>>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>>> AbstractCommand.java:35)
>>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>>> Closure.java:400)
>>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>>> at
>>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>>> CommandSessionImpl.java:89)
>>>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>>> NativeMethodAccessorImpl.java:39)
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>>> DelegatingMethodAccessorImpl.java:25)
>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>>>> Error executing command: java.lang.NullPointerException
>>>>
>>>> As this code is really hard to debug as we have embedded the code of
>>>> org.apache.felix.gogo.runtime
>>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
>>>> anybody knows why I could get a NPE when we call this method. In debug
>>>> mode, I confirm that the session object exists but the command is null
>>>> (even if I'm able to recuperate the args 'help echo' and this command
>>>> works
>>>> 'echo blabla'
>>>>
>>>> Regards,
>>>>
>>>>
>>>>  --
>>> 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
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: NPE with command Help & Karaf Shell Console

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

do you have description attribute on the @Command annotation ?

Regards
JB

On 11/29/2013 10:32 AM, Charles Moulliard wrote:
> 2.3.3
>
>
> On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:
>
>> Hi Charles,
>>
>> what's the Karaf version (as it changed between 2.x and 3.x) ?
>>
>> Regards
>> JB
>>
>>
>> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>>
>>> Hi,
>>>
>>> For a documentation project, I'm currently creating a Java Command Line
>>> Tool client using our excellent Apache Karaf Shell Console. Nevertheless,
>>> when I try to get help from a command, Gogo & Felix returns a NPE
>>>
>>> HylaMain
>>> java.io.BufferedInputStream@9506dc4
>>> hyla>echo blabla
>>> echo blabla
>>> blabla
>>> hyla>help echo
>>> help echo
>>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>>> caught while executing command
>>> java.lang.NullPointerException
>>> at
>>> org.apache.karaf.shell.console.help.HelpAction.
>>> doExecute(HelpAction.java:40)
>>> at
>>> org.apache.karaf.shell.console.AbstractAction.
>>> execute(AbstractAction.java:33)
>>> at
>>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>>> AbstractCommand.java:35)
>>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>>> Closure.java:400)
>>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>>> at
>>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>>> CommandSessionImpl.java:89)
>>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(
>>> NativeMethodAccessorImpl.java:39)
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>>> DelegatingMethodAccessorImpl.java:25)
>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>>> Error executing command: java.lang.NullPointerException
>>>
>>> As this code is really hard to debug as we have embedded the code of
>>> org.apache.felix.gogo.runtime
>>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
>>> anybody knows why I could get a NPE when we call this method. In debug
>>> mode, I confirm that the session object exists but the command is null
>>> (even if I'm able to recuperate the args 'help echo' and this command
>>> works
>>> 'echo blabla'
>>>
>>> Regards,
>>>
>>>
>> --
>> 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: NPE with command Help & Karaf Shell Console

Posted by Charles Moulliard <ch...@gmail.com>.
2.3.3


On Fri, Nov 29, 2013 at 10:31 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Charles,
>
> what's the Karaf version (as it changed between 2.x and 3.x) ?
>
> Regards
> JB
>
>
> On 11/29/2013 10:18 AM, Charles Moulliard wrote:
>
>> Hi,
>>
>> For a documentation project, I'm currently creating a Java Command Line
>> Tool client using our excellent Apache Karaf Shell Console. Nevertheless,
>> when I try to get help from a command, Gogo & Felix returns a NPE
>>
>> HylaMain
>> java.io.BufferedInputStream@9506dc4
>> hyla>echo blabla
>> echo blabla
>> blabla
>> hyla>help echo
>> help echo
>> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
>> caught while executing command
>> java.lang.NullPointerException
>> at
>> org.apache.karaf.shell.console.help.HelpAction.
>> doExecute(HelpAction.java:40)
>> at
>> org.apache.karaf.shell.console.AbstractAction.
>> execute(AbstractAction.java:33)
>> at
>> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(
>> AbstractCommand.java:35)
>> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
>> at org.apache.felix.gogo.runtime.Closure.executeStatement(
>> Closure.java:400)
>> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
>> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
>> at
>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(
>> CommandSessionImpl.java:89)
>> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
>> at org.apache.karaf.shell.console.Main.run(Main.java:220)
>> at org.apache.karaf.shell.console.Main.run(Main.java:164)
>> at org.apache.karaf.shell.console.Main.run(Main.java:79)
>> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(
>> NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(
>> DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>> Error executing command: java.lang.NullPointerException
>>
>> As this code is really hard to debug as we have embedded the code of
>> org.apache.felix.gogo.runtime
>> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
>> anybody knows why I could get a NPE when we call this method. In debug
>> mode, I confirm that the session object exists but the command is null
>> (even if I'm able to recuperate the args 'help echo' and this command
>> works
>> 'echo blabla'
>>
>> Regards,
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

Re: NPE with command Help & Karaf Shell Console

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

what's the Karaf version (as it changed between 2.x and 3.x) ?

Regards
JB

On 11/29/2013 10:18 AM, Charles Moulliard wrote:
> Hi,
>
> For a documentation project, I'm currently creating a Java Command Line
> Tool client using our excellent Apache Karaf Shell Console. Nevertheless,
> when I try to get help from a command, Gogo & Felix returns a NPE
>
> HylaMain
> java.io.BufferedInputStream@9506dc4
> hyla>echo blabla
> echo blabla
> blabla
> hyla>help echo
> help echo
> [main] ERROR org.apache.karaf.shell.console.jline.Console - Exception
> caught while executing command
> java.lang.NullPointerException
> at
> org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)
> at
> org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)
> at
> org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)
> at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)
> at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
> at
> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
> at org.apache.karaf.shell.console.jline.Console.run(Console.java:173)
> at org.apache.karaf.shell.console.Main.run(Main.java:220)
> at org.apache.karaf.shell.console.Main.run(Main.java:164)
> at org.apache.karaf.shell.console.Main.run(Main.java:79)
> at com.redhat.gpe.hyla.tooling.HylaMain.main(HylaMain.java:34)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Error executing command: java.lang.NullPointerException
>
> As this code is really hard to debug as we have embedded the code of
> org.apache.felix.gogo.runtime
> & org.apache.felix.gogo.commands in the jar of Karaf Shell Console, does
> anybody knows why I could get a NPE when we call this method. In debug
> mode, I confirm that the session object exists but the command is null
> (even if I'm able to recuperate the args 'help echo' and this command works
> 'echo blabla'
>
> Regards,
>

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