AnsweredAssumed Answered

NPE with REST and Camel

Question asked by mallux on Jun 26, 2013
Latest reply on Sep 6, 2013 by smirzai
Hi

When starting a camel process instance from a rest post, I'm getting a Null Pointer Exception on the receive - so the instance gets stuck waiting for a receive which never arrives.  I can invoke the same process from explorer and it completes fine.

I've reproduced this using the async Camel example (https://github.com/Activiti/Activiti/blob/activiti-5.13/modules/activiti-camel/src/test/resources/process/async.bpmn20.xml) - the stack trace is below.  Am I doing something daft?

thanks
Chris


03:28:27,515 [Camel (camelContext) thread #3 - seda://asyncQueue2] DEBUG org.apache.camel.processor.SendProcessor  - >>>> Endpoint[seda://receiveQueue] Exchange[Message: [Body is null]]
03:28:27,515 [Camel (camelContext) thread #2 - seda://asyncQueue] DEBUG org.apache.camel.processor.SendProcessor  - >>>> Endpoint[seda://receiveQueue] Exchange[Message: [Body is null]]
03:28:27,521 [Camel (camelContext) thread #4 - seda://receiveQueue] DEBUG org.apache.camel.impl.DefaultComponent  - Creating endpoint uri=[activiti://asyncCamelProcess:receive2], path=[asyncCamelProcess:receive2]
03:28:27,525 [Camel (camelContext) thread #4 - seda://receiveQueue] DEBUG org.apache.camel.spring.SpringCamelContext  - activiti://asyncCamelProcess:receive2 converted to endpoint: Endpoint[activiti://asyncCamelProcess:receive2] by component: org.activiti.camel.ActivitiComponent@10bcc8f4
03:28:27,526 [Camel (camelContext) thread #4 - seda://receiveQueue] DEBUG org.apache.camel.impl.ProducerCache  - Adding to producer cache with key: Endpoint[activiti://asyncCamelProcess:receive2] for producer: Producer[activiti://asyncCamelProcess:receive2]
03:28:27,533 [Camel (camelContext) thread #4 - seda://receiveQueue] DEBUG org.apache.camel.processor.DefaultErrorHandler  - Redelivery enabled: false on error handler: DefaultErrorHandler[Producer[activiti://asyncCamelProcess:receive2]]
03:28:27,546 [Camel (camelContext) thread #4 - seda://receiveQueue] DEBUG org.apache.camel.processor.DefaultErrorHandler  - Failed delivery for (MessageId: ID-activapp-2ed77445-eb8c-4f6a-86e3-b6ef5923d024-34620-1372260329571-0-4 on ExchangeId: ID-activapp-2ed77445-eb8c-4f6a-86e3-b6ef5923d024-34620-1372260329571-0-8). On delivery attempt: 0 caught: java.lang.NullPointerException
03:28:27,550 [Camel (camelContext) thread #4 - seda://receiveQueue] ERROR org.apache.camel.processor.DefaultErrorHandler  - Failed delivery for (MessageId: ID-activapp-2ed77445-eb8c-4f6a-86e3-b6ef5923d024-34620-1372260329571-0-4 on ExchangeId: ID-activapp-2ed77445-eb8c-4f6a-86e3-b6ef5923d024-34620-1372260329571-0-8). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
java.lang.NullPointerException
   at org.activiti.camel.ActivitiProducer.signal(ActivitiProducer.java:59)
   at org.activiti.camel.ActivitiProducer.process(ActivitiProducer.java:49)
   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.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:390)
   at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
   at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
   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.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
   at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:571)
   at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:504)
   at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:213)
   at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
   at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:151)
   at org.apache.camel.processor.RecipientList.process(RecipientList.java:112)
   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.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:72)
   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.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
   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:390)
   at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
   at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
   at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
   at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
   at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
   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:72)
   at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
   at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:275)
   at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:183)
   at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:139)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:679)


camel context:


    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
        <packageScan>
            <package>org.activiti.camel.route</package>
        </packageScan>
    </camelContext>

    <bean id="sleepBean" class="org.activiti.camel.util.SleepBean"/>


route:


    from("activiti:asyncCamelProcess:serviceTaskAsync1").setHeader("destination", constant("activiti:asyncCamelProcess:receive1")).to("seda:asyncQueue");
    from("seda:asyncQueue").to("bean:sleepBean?method=sleep").to("seda:receiveQueue");

    from("activiti:asyncCamelProcess:serviceTaskAsync2").setHeader("destination", constant("activiti:asyncCamelProcess:receive2")).to("seda:asyncQueue2");
    from("seda:asyncQueue2").to("bean:sleepBean?method=sleep").to("seda:receiveQueue");

    from("seda:receiveQueue").recipientList(header("destination"));


POST body:

{
   "processDefinitionKey":"asyncCamelProcess",
   
   "variables" : [ ]
}

Outcomes