title: Running Kafka consumer inside Apache ServiceMix
body: <p>I am trying to create a bundle using camel-kafka, and run it inside servicemix. The module is a very basic kafka consumer which uses camel-kafka connector, and consumes messages from a kafka topic.  I am able to  successfully run the module using mvn camel:run, however installing the same module inside service mix as a osgi bundle gives following error:</p>
  
  <pre><code>014-11-03 21:07:25,929 | ERROR | rint Extender: 1 | BlueprintContainerImpl           | ?                                   ? | 17 - org.apache.aries.blueprint.core - 1.4.1 | Unable to start blueprint container for bundle kafka-test due to unresolved dependencies [(&amp;(component=kafka)(objectClass=org.apache.camel.spi.ComponentResolver))]
  java.util.concurrent.TimeoutException
      at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:336)[17:org.apache.aries.blueprint.core:1.4.1]
      at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[17:org.apache.aries.blueprint.core:1.4.1]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_67]
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_67]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_67]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_67]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_67]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_67]
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>The above warning got resolved after installing camel-kafka feature in the servicemix. (Thanks to <a href="https://stackoverflow.com/users/1242093/achim-nierbeck">Achim</a>)  However, then i started getting the following error:</p>
  
  <pre><code>EventDispatcher: Error during dispatch. (java.lang.NoClassDefFoundError: org/I0Itec/zkclient/serialize/ZkSerializer)
  java.lang.NoClassDefFoundError: org/I0Itec/zkclient/serialize/ZkSerializer
      at kafka.javaapi.consumer.ZookeeperConsumerConnector.&lt;init&gt;(ZookeeperConsumerConnector.scala:65)
      at kafka.javaapi.consumer.ZookeeperConsumerConnector.&lt;init&gt;(ZookeeperConsumerConnector.scala:67)
      at kafka.consumer.Consumer$.createJavaConsumerConnector(ConsumerConnector.scala:100)
      at kafka.consumer.Consumer.createJavaConsumerConnector(ConsumerConnector.scala)
      at org.apache.camel.component.kafka.KafkaConsumer.doStart(KafkaConsumer.java:72)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
      at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:2042)
      at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:2336)
      at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:2272)
      at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:2202)
      at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1981)
      at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1851)
      at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1683)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
      at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1651)
      at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:177)
      at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:209)
      at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:147)
      at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:943)
      at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:794)
      at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:544)
      at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4445)
      at org.apache.felix.framework.Felix.registerService(Felix.java:3431)
      at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
      at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:353)
      at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:97)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)
      at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)
      at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)
      at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)
      at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)
      at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
      at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
      at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:681)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:378)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)
      at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)
      at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)
      at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)
      at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
      at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
      at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
      at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
      at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)
      at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)
      at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)
      at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)
      at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4429)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:2100)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)
      at org.apache.karaf.shell.osgi.InstallBundle.doExecute(InstallBundle.java:51)
      at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
      at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
      at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)
      at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
      at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
      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:92)
      at org.apache.karaf.shell.console.jline.Console.run(Console.java:196)
      at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:79)
  Caused by: java.lang.ClassNotFoundException: org.I0Itec.zkclient.serialize.ZkSerializer not found by org.apache.servicemix.bundles.kafka_2.10 [217]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1556)
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      ... 70 more
  </code></pre>
  
  <p>I installed zkclient using osgi:install by downloading 0.4 and 0.3 jar files from <a href="http://mvnrepository.com/artifact/com.101tec/zkclient" rel="nofollow noreferrer">maven</a> repository. However, the namespace of this module is <strong>com.101tec</strong>, whereas the error is pointing to <strong>org.101tec</strong> .  I am not sure how to proceed here.  Any pointers will be really helpful.</p>