Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13461

Http4 Component is not propagated correctly in OSGI environment

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.23.1
    • Fix Version/s: None
    • Component/s: camel-http4
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      I'm using Camel 2.23.1 with Karaf 4.2.5, with following features installed:

      camel camel-scr camel-stream camel-http4 camel-jackson camel-kafka camel-quartz2
      

      I have one bundle (let's call it context-provder) which consists of Activator only:

      public class Activator implements BundleActivator {
        private ServiceRegistration<CamelContext> registrationCamelContext;
        private CamelContext camelContext;
      
        @Override
        public void start(final BundleContext bundleContext) throws Exception {
          camelContext = new OsgiDefaultCamelContext(bundleContext);
          registrationCamelContext = bundleContext.registerService(CamelContext.class, camelContext, null);
          camelContext.start();
        }
      }
      

       And the second bundle (let's call it context-consumer) which uses several Camel componets (kafka, quartz2, http4)

      @Component(
          immediate = true,
          service = MyService.class
      )
      public class MyServiceImpl implements MyService {
      
        @Activate
        public NotificationServiceImpl(@Reference final CamelContext camelContext) throws Exception {
          super(camelContext)
          camelContext.addRoutes(this);
        }
       @Override
        public void configure() throws Exception {
           //routes using http4, quartz2, kafka etc.
        }
      }
      

      While all other routes are "seen" by Camel and work without any problems, http4 is exception to the rule.
      Camel throws:

      org.apache.karaf.features.internal.util.MultiException: Error restarting bundles:
              Activator start error in bundle context.consumer [150].
              at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:1005)
              at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1058)
              at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:994)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
              at java.base/java.lang.Thread.run(Thread.java:844)
              Suppressed: org.osgi.framework.BundleException: Activator start error in bundle context.consumer [150].
                      at org.apache.felix.framework.Felix.activateBundle(Felix.java:2290)
                      at org.apache.felix.framework.Felix.startBundle(Felix.java:2146)
                      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
                      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
                      at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.startBundle(BundleInstallSupportImpl.java:161)
                      at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1149)
                      at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:997)
                      ... 6 more
              Caused by: java.lang.IllegalArgumentException: Cannot find endpoint with scheme https4
                      at org.apache.camel.runtimecatalog.AbstractCamelCatalog.endpointProperties(AbstractCamelCatalog.java:542)
                      at org.apache.camel.http.common.HttpSendDynamicAware.prepare(HttpSendDynamicAware.java:57)
                      at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:118)
                      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
                      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
                      at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
                      at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
                      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
                      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
                      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:60)
                      at org.apache.camel.impl.DeferProducer.process(DeferProducer.java:72)
                      at org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:193)
                      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
                      at org.apache.camel.component.bean.AbstractCamelInvocationHandler.doInvoke(AbstractCamelInvocationHandler.java:211)
                      at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeProxy(AbstractCamelInvocationHandler.java:173)
                      at org.apache.camel.component.bean.CamelInvocationHandler.doInvokeProxy(CamelInvocationHandler.java:51)
                      at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invoke(AbstractCamelInvocationHandler.java:90)
                      at com.sun.proxy.$Proxy113.send(Unknown Source)
                      at context.consumer.MyServiceImpl.callCamel(MyServiceImpl.java:87)
                      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
                      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
                      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
                      at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
                      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
                      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
                      at context.consumer.MyActivator.start(MyActivator.java:43)
                      at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
                      at org.apache.felix.framework.Felix.activateBundle(Felix.java:2240)
                      ... 12 more
      

      While - as I said - other components works just fine.

      One of the workaround is to move Activator to context-consumer bundle - then Camel magically starts to "see" http4 component.

      Other workaround is to register component explicitly by:

      camelContext.addComponent("http4", new HttpComponent());
      

      in the context-provider Activator, but then - why kafka and quartz2 does not have such problems?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eximius Kamil
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: