title: How to use an OSGI bundle within a camel route?
body: <p>I have problems using a OSGI-Service in a camel route. Read <a href="http://camel.apache.org/tutorial-osgi-camel-part1.html" rel="nofollow">tutorial-osgi-camel-part1
  </a> but didn't get it to work.</p>
  
  <p>The setup:</p>
  
  <ul>
  <li>bundle 1 defines a Service interface (separate bundle for interface because there can be several implementations of it)</li>
  <li>bundle 2 implements this interface</li>
  <li>bundle 3 should use bundle 2 that provides interface from bundle 1</li>
  </ul>
  
  <p>In bundle 2 (the implementation) are the two xml files, one with</p>
  
  <pre><code>&lt;osgi:service ref="invokeService"&gt;
      &lt;osgi:interfaces&gt;
          &lt;value&gt;invoker.Invoker&lt;/value&gt;
      &lt;/osgi:interfaces&gt;
  &lt;/osgi:service&gt; 
  </code></pre>
  
  <p>and the other with</p>
  
  <pre><code>&lt;bean id="invokeService" class="invokerImpl.InvokerImpl"&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Bundle 3 has a xml file with</p>
  
  <pre><code> &lt;osgi:reference id="invokeService" interface="invoker.Invoker"/&gt;
  </code></pre>
  
  <p>in it. 
  Bundle 3 and the CamelContext is started with</p>
  
  <pre><code>@Override
  public void start(BundleContext bundleContext) throws Exception {
      OsgiDefaultCamelContext camelContext = new OsgiDefaultCamelContext(bundleContext);
      camelContext.addRoutes(new ExampleRoute());
      camelContext.start();
  }
  </code></pre>
  
  <p>In my route I want to use the Service (from bundle 2) with</p>
  
  <pre><code>.to("bean:invokeService")
  </code></pre>
  
  <p>Exception I get:</p>
  
  <pre><code>19:14:39.953  TRACE  o.a.camel.core.osgi.OsgiClassResolver:42       Resolve class invokeService
  19:14:39.969  TRACE  o.a.camel.core.osgi.OsgiClassResolver:84       Cannot load class: invokeService using classloader: CamleOSGIExample_1.0.0.qualifier [254]. This exception be ignored.
  java.lang.ClassNotFoundException: invokeService
  at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513) ~[na:na]
  at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) ~[na:na]
  (...)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: invokeService
      at org.apache.camel.component.bean.RegistryBean.getBean(RegistryBean.java:68) ~[camel-core-2.10.3.jar:2.10.3]
      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:83) ~[camel-core-2.10.3.jar:2.10.3]
  </code></pre>
  
  <p>I'm using Equinox.</p>