2 Replies Latest reply: Jun 21, 2012 1:38 PM by Eduardo de Vera Toquero RSS

    Forge + Camel Route + JMS Binding results into NullPointerException

    Eduardo de Vera Toquero Newbie

      When using Forge in order to build my project in order to create a camel service, a bean service and then a camel jms binding to the first service I get the following switchyard xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0">

          <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"

                     name="TestComposite"

                     targetNamespace="urn:switchyard:application:1.0">

              <service name="MyService" promote="MyService">

                  <binding.camel xmlns="urn:switchyard-component-camel:config:1.0" configURI="jms://MyQueue?connectionFactory=#ConnectionFactory"/>

              </service>

              <component name="MyServiceBuilder">

                  <implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">

                      <java class="org.switchyard.examples.forge.MyServiceBuilder"/>

                  </implementation.camel>

                  <service name="MyService">

                      <interface.java interface="org.switchyard.examples.forge.MyService"/>

                  </service>

                  <reference name="OrderService">

                      <interface.java interface="org.switchyard.examples.forge.OrderService"/>

                  </reference>

              </component>

          </composite>

      </switchyard>

       

      If I try to run a JUnit test with the Switchyard runner (or by directly deploying it in JBoss Switchyard) I get the following NullpointerException:

       

      18:56:32,077 ERROR [processor.DefaultErrorHandler] Failed delivery for (MessageId: ID:0d5f632f-bbc2-11e1-bfbe-e0f847371cc8 on ExchangeId: ID-macbookpro-54457-1340297791030-1-1). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException

      java.lang.NullPointerException

                at org.switchyard.component.camel.SwitchYardProducer.lookupOperationNameFor(SwitchYardProducer.java:119)

                at org.switchyard.component.camel.SwitchYardProducer.createSwitchyardExchange(SwitchYardProducer.java:102)

                at org.switchyard.component.camel.SwitchYardProducer.process(SwitchYardProducer.java:81)

                at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)

                at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)

                at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333)

                at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223)

                at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)

                at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)

                at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)

                at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:50)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)

                at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:104)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)

                at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)

                at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:680)

      18:56:32,089 WARN  [jms.EndpointMessageListener] Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.NullPointerException]

      org.apache.camel.RuntimeCamelException: java.lang.NullPointerException

                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)

                at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:187)

                at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:108)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)

                at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)

                at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)

                at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)

                at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:680)

      Caused by: java.lang.NullPointerException

                at org.switchyard.component.camel.SwitchYardProducer.lookupOperationNameFor(SwitchYardProducer.java:119)

                at org.switchyard.component.camel.SwitchYardProducer.createSwitchyardExchange(SwitchYardProducer.java:102)

                at org.switchyard.component.camel.SwitchYardProducer.process(SwitchYardProducer.java:81)

                at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)

                at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)

                at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333)

                at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223)

                at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)

                at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)

                at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)

                at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:50)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

                at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

                at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)

                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)

                at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)

                at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:104)

                ... 11 more

       

      If I then add the following element to the switchyard.xml file, then everything works:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0">

          <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"

                     name="TestComposite"

                     targetNamespace="urn:switchyard:application:1.0">

              <service name="MyService" promote="MyService">

                  <interface.java interface="org.switchyard.examples.forge.MyService" />

                  <binding.camel xmlns="urn:switchyard-component-camel:config:1.0" configURI="jms://MyQueue?connectionFactory=#ConnectionFactory"/>

              </service>

              <component name="MyServiceBuilder">

                  <implementation.camel xmlns="urn:switchyard-component-camel:config:1.0">

                      <java class="org.switchyard.examples.forge.MyServiceBuilder"/>

                  </implementation.camel>

                  <service name="MyService">

                      <interface.java interface="org.switchyard.examples.forge.MyService"/>

                  </service>

                  <reference name="OrderService">

                      <interface.java interface="org.switchyard.examples.forge.OrderService"/>

                  </reference>

              </component>

          </composite>

      </switchyard>

       

      I do find it a bit strange that I have to define the same interface twice for the same service. I believe that if instead of a Camel Service bound to a JMS Camel binding I use a Bean Service, I don't need to additionally add the interface.java element in the top level promoted service element.

       

      Would this be considered a forge bug, a switchyard plugin bug or a wrong use from my side to the tools?