Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-1954

NullPointerException on custom Karaf shell command: ClassNotFoundException: org.apache.felix.service.command.Function not found

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.3.0
    • None
    • karaf
    • None

    Description

      I have a shell command extending OsgiSupportCommand which always throws NullPointerException no matter what.

      karaf@root> as:json
      Error executing command: java.lang.NullPointerException
      

      trace:

      2012-10-19 21:10:43,862 | ERROR | l Console Thread | ServiceRecipe                    | lueprint.container.ServiceRecipe  294 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.jline.Console.run(Console.java:175)[14:org.apache.karaf.shell.console:2.3.0]
              at java.lang.Thread.run(Thread.java:722)[:1.7.0_07]
      2012-10-19 21:10:43,863 | ERROR | l Console Thread | ServiceRecipe                    | lueprint.container.ServiceRecipe  323 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:295)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.jline.Console.run(Console.java:175)[14:org.apache.karaf.shell.console:2.3.0]
              at java.lang.Thread.run(Thread.java:722)[:1.7.0_07]
      Caused by: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              ... 18 more
      2012-10-19 21:10:43,865 | INFO  | l Console Thread | Console                          | araf.shell.console.jline.Console  199 | 14 - org.apache.karaf.shell.console - 2.3.0 | Exception caught while executing command
      java.lang.NullPointerException
              at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:61)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.jline.Console.run(Console.java:175)[14:org.apache.karaf.shell.console:2.3.0]
              at java.lang.Thread.run(Thread.java:722)[:1.7.0_07]
      

      "help as:json" throws:

      2012-10-19 21:14:23,816 | ERROR | -[*:help, $args] | ServiceRecipe                    | lueprint.container.ServiceRecipe  294 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.SingleCommandHelpProvider.getHelp(SingleCommandHelpProvider.java:51)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem$1.getValue(HelpSystem.java:71)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.substVars(InterpolationHelper.java:174)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.performSubstitution(InterpolationHelper.java:84)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem.getHelp(HelpSystem.java:68)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
      2012-10-19 21:14:23,818 | ERROR | -[*:help, $args] | ServiceRecipe                    | lueprint.container.ServiceRecipe  323 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:295)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.SingleCommandHelpProvider.getHelp(SingleCommandHelpProvider.java:51)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem$1.getValue(HelpSystem.java:71)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.substVars(InterpolationHelper.java:174)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.performSubstitution(InterpolationHelper.java:84)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem.getHelp(HelpSystem.java:68)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
      Caused by: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              ... 28 more
      

      "as:json --help" throws:

      2012-10-19 18:24:14,515 | ERROR | -[*:help, $args] | ServiceRecipe                    | lueprint.container.ServiceRecipe  294 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.SingleCommandHelpProvider.getHelp(SingleCommandHelpProvider.java:51)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem$1.getValue(HelpSystem.java:71)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.substVars(InterpolationHelper.java:174)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.performSubstitution(InterpolationHelper.java:84)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem.getHelp(HelpSystem.java:68)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
      2012-10-19 18:24:14,517 | ERROR | -[*:help, $args] | ServiceRecipe                    | lueprint.container.ServiceRecipe  323 | 7 - org.apache.aries.blueprint.core - 1.0.1 | Error retrieving service from ServiceRecipe[name='shell-350']
      org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:295)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.internalGetService(ServiceRecipe.java:247)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getService(ServiceRecipe.java:349)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe$TriggerServiceFactory.getService(ServiceRecipe.java:502)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:308)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:219)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:310)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.Felix.getService(Felix.java:3420)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:468)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.gogo.runtime.CommandProxy.getTarget(CommandProxy.java:50)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:72)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.SingleCommandHelpProvider.getHelp(SingleCommandHelpProvider.java:51)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem$1.getValue(HelpSystem.java:71)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.substVars(InterpolationHelper.java:174)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.util.InterpolationHelper.performSubstitution(InterpolationHelper.java:84)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpSystem.getHelp(HelpSystem.java:68)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.help.HelpAction.doExecute(HelpAction.java:40)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[14:org.apache.karaf.shell.console:2.3.0]
              at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[14:org.apache.karaf.shell.console:2.3.0]
      Caused by: java.lang.ClassNotFoundException: org.apache.felix.service.command.Function not found by soluvas-json [1774]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)[org.apache.felix.framework-4.0.3.jar:]
              at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_07]
              at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1723)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:926)[org.apache.felix.framework-4.0.3.jar:]
              at org.apache.aries.blueprint.container.BlueprintContainerImpl.loadClass(BlueprintContainerImpl.java:401)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.convertStringsToClasses(ServiceRecipe.java:416)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.getClassesForProxying(ServiceRecipe.java:406)[7:org.apache.aries.blueprint.core:1.0.1]
              at org.apache.aries.blueprint.container.ServiceRecipe.createService(ServiceRecipe.java:288)[7:org.apache.aries.blueprint.core:1.0.1]
              ... 28 more
      

      The actual code is not even executed yet.

      Command :

      package org.soluvas.json;
      
      import org.apache.felix.gogo.commands.Argument;
      import org.apache.felix.gogo.commands.Command;
      import org.apache.karaf.shell.console.OsgiCommandSupport;
      
      import com.fasterxml.jackson.databind.ObjectMapper;
      
      /**
       * Format any object as JSON.
       * @author ceefour
       */
      @Command(scope="as", name="json", description="Format any object as JSON.")
      public class AsJsonCommand extends OsgiCommandSupport {
      	
      //	private transient Logger log = LoggerFactory.getLogger(AsJsonCommand.class);
      	
      	private ObjectMapper mapper;
      	
      	@Argument(name="object", required=true, description="Object to format as JSON, e.g. (process:find hello).")
      	private Object input;
      	
      	public AsJsonCommand(ObjectMapper mapper) {
      		super();
      		this.mapper = mapper;
      	}
      
      	/* (non-Javadoc)
      	 * @see org.apache.karaf.shell.console.AbstractAction#doExecute()
      	 */
      	@Override
      	protected Object doExecute() throws Exception {
      		return mapper.writeValueAsString(input);
      	}
      
      }
      

      Blueprint :

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0
              http://karaf.apache.org/xmlns/shell/v1.1.0 http://karaf.apache.org/xmlns/shell/v1.1.0">
      
      	<reference-list id="jacksonModuleSuppliers" interface="com.google.common.base.Supplier"
      		filter="(className=com.fasterxml.jackson.databind.Module)" availability="optional"/>
      	<bean id="jacksonMapperFactory" class="org.soluvas.json.JacksonMapperFactoryImpl"
      		depends-on="jacksonModuleSuppliers">
      		<argument ref="jacksonModuleSuppliers"/>
      	</bean>
      	<service ref="jacksonMapperFactory" auto-export="interfaces">
      		<service-properties>
      			<entry key="className" value="com.fasterxml.jackson.databind.ObjectMapper"/>
      		</service-properties>
      	</service>
      	<bean id="jacksonMapper" factory-ref="jacksonMapperFactory" factory-method="get"
      		scope="prototype"/>
      
      	<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
      		<command name="as/json">
      			<action class="org.soluvas.json.AsJsonCommand">
      				<argument ref="jacksonMapper"/>
      			</action>
      		</command>
      	</command-bundle>
      
      </blueprint>
      

      Note: This is an open source project at: https://github.com/soluvas/soluvas-framework/tree/master/json

      Attachments

        1. karaf1954.zip
          8 kB
          Gavin Scott

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            ceefour Hendy Irawan
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: