4 Replies Latest reply on Jul 30, 2013 7:28 AM by Tadayoshi Sato

    NPE occurs in unit tests when a service has two File bindings

    Tadayoshi Sato Novice

      Hello folks,

       

      I'm trying to create a SY application with the following switchyard.xml:

       

        <sca:composite name="camel_helloworld" targetNamespace="urn:switchyard-quickstart:camel_helloworld:1.0">
          <sca:service name="service1" promote="camel_helloworld/service1">
            <file:binding.file>
              <file:contextMapper/>
              <file:directory>${project.build.directory}/input1</file:directory>
              <file:consume>
                <file:initialDelay>10</file:initialDelay>
                <file:delay>10</file:delay>
                <file:delete>true</file:delete>
              </file:consume>
            </file:binding.file>
            <file:binding.file>
              <file:contextMapper/>
              <file:directory>${project.build.directory}/input2</file:directory>
              <file:consume>
                <file:initialDelay>10</file:initialDelay>
                <file:delay>10</file:delay>
                <file:delete>true</file:delete>
              </file:consume>
            </file:binding.file>
          </sca:service>
          ...
      

       

      However, when testing it using SwitchYardRunner I always get the following NPE only at the beginning of the test run. Note that with some other combinations of 'initialDelay' and 'delay', this NPE won't occur; for instance, I can run the tests successfully with 'initialDelay' = 100 and 'delay' = 100 for the both file bindings. And it also won't occur deployed on the JBoss server.

       

      17:47:00,121 ERROR [org.apache.camel.processor.DefaultErrorHandler] Failed delivery for (MessageId: ID-reunion-59884-1375087618618-0-2 on ExchangeId: ID-reunion-59884-1375087618618-0-3). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
      java.lang.NullPointerException
                at com.sun.org.apache.xerces.internal.dom.ParentNode.nodeListItem(ParentNode.java:776)
                at com.sun.org.apache.xerces.internal.dom.ParentNode.item(ParentNode.java:800)
                at org.switchyard.config.DOMConfiguration.getFirstChild(DOMConfiguration.java:500)
                at org.switchyard.config.model.BaseModel.getFirstChildModel(BaseModel.java:270)
                at org.switchyard.config.model.composite.v1.V1BindingModel.getContextMapper(V1BindingModel.java:133)
                at org.switchyard.component.camel.common.composer.CamelComposition.getMessageComposer(CamelComposition.java:48)
                at org.switchyard.component.camel.common.handler.MessageComposerProcessor.process(MessageComposerProcessor.java:48)
                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.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                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:73)
                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:330)
                at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
                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:303)
                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
                at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
                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:48)
                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:73)
                at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:336)
                at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:189)
                at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:155)
                at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:139)
                at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:91)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
                at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
                at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
                at java.lang.Thread.run(Thread.java:722)
      

       

      Why does this error happen?  Is this a bug in the Camel File binding?

       

      I've attached the entire project for your reference.

       

      Thank you,

      Tadayoshi