You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ethan Aubin <et...@gmail.com> on 2009/06/02 17:02:26 UTC

all messages go to dead letter channel

Hi, I'm trying to write a camel component which reads a value from a
socket and logs the results. I'm doing something wrong in the
component or in the configuration of my route as the value always is
delivered to the dead letter channel and fails with the following
exception

SEVERE: Failed delivery for exchangeId:
ID-eaubin-1/51474-1243953466200/1-3. On delivery attempt: 0 caught:
java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
org.apache.camel.converter.stream.StreamCache
java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
org.apache.camel.converter.stream.StreamCache
at org.apache.camel.component.log.LogFormatter.getBodyAsString(LogFormatter.java:182)
at org.apache.camel.component.log.LogFormatter.format(LogFormatter.java:74)
at org.apache.camel.processor.Logger.logMessage(Logger.java:234)
at org.apache.camel.processor.Logger.process(Logger.java:88)
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
at java.lang.Thread.run(Thread.java:637)
java.lang.NullPointerException
at org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:49)
at org.apache.camel.processor.DeadLetterChannel.incrementRedeliveryCounter(DeadLetterChannel.java:430)
at org.apache.camel.processor.DeadLetterChannel.handleException(DeadLetterChannel.java:287)
at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:162)
at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
at java.lang.Thread.run(Thread.java:637)


Camel is started using

       context = new DefaultCamelContext(new JndiRegistry());
       context.addComponent("xmltcp", new XmlTcpComponent(context));
       ccEndpoint = context.getEndpoint("xmltcp://127.0.0.1:15001");
       context.addRoutes(new RouteBuilder() {
           @Override
           public void configure() {
               from(ccEndpoint).to("log:loggingCategoryFoo?level=INFO");
           }
       });
       context.start();

After the value has been read from the socket the consumer delivers it with:

           DefaultMessage msg = new DefaultMessage();
           msg.setBody(obj);
           XmlTcpExchange ex = endpoint.createExchange();
           ex.setIn(msg);
           getProcessor().process(ex);


The consumer, component, endpoint and exchange all inherit from
default classes and don't do anything particularly interesting  (I can
send the code if that would help). What could be going on here? Many
thanks  - Ethan

Re: all messages go to dead letter channel

Posted by Ethan Aubin <et...@gmail.com>.
The particular error happens in both 1.6.0 and 2.0, but it turns out
the Claus found the source of the problem.  I was using an endpoint
which never explicitly set the camel context and the null is just the
default value from DefaultEndpoint.  Thanks for the help! - Ethan

On Wed, Jun 3, 2009 at 11:33 PM, Willem Jiang <wi...@gmail.com> wrote:
> Which version of Camel are you using?
> Can you try the last released Camel 1.6.1 ?
> I just check the latest code repository, we did some improvements on the
> LogFormatter and you should not get ClassCastException here :).
>
> Willem
>
>
> Ethan Aubin wrote:
>> Hi, I'm trying to write a camel component which reads a value from a
>> socket and logs the results. I'm doing something wrong in the
>> component or in the configuration of my route as the value always is
>> delivered to the dead letter channel and fails with the following
>> exception
>>
>> SEVERE: Failed delivery for exchangeId:
>> ID-eaubin-1/51474-1243953466200/1-3. On delivery attempt: 0 caught:
>> java.lang.ClassCastException:
>> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
>> org.apache.camel.converter.stream.StreamCache
>> java.lang.ClassCastException:
>> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
>> org.apache.camel.converter.stream.StreamCache
>> at org.apache.camel.component.log.LogFormatter.getBodyAsString(LogFormatter.java:182)
>> at org.apache.camel.component.log.LogFormatter.format(LogFormatter.java:74)
>> at org.apache.camel.processor.Logger.logMessage(Logger.java:234)
>> at org.apache.camel.processor.Logger.process(Logger.java:88)
>> at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
>> at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
>> at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
>> at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
>> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
>> at java.lang.Thread.run(Thread.java:637)
>> java.lang.NullPointerException
>> at org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:49)
>> at org.apache.camel.processor.DeadLetterChannel.incrementRedeliveryCounter(DeadLetterChannel.java:430)
>> at org.apache.camel.processor.DeadLetterChannel.handleException(DeadLetterChannel.java:287)
>> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:162)
>> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
>> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
>> at java.lang.Thread.run(Thread.java:637)
>>
>>
>> Camel is started using
>>
>>        context = new DefaultCamelContext(new JndiRegistry());
>>        context.addComponent("xmltcp", new XmlTcpComponent(context));
>>        ccEndpoint = context.getEndpoint("xmltcp://127.0.0.1:15001");
>>        context.addRoutes(new RouteBuilder() {
>>            @Override
>>            public void configure() {
>>                from(ccEndpoint).to("log:loggingCategoryFoo?level=INFO");
>>            }
>>        });
>>        context.start();
>>
>> After the value has been read from the socket the consumer delivers it with:
>>
>>            DefaultMessage msg = new DefaultMessage();
>>            msg.setBody(obj);
>>            XmlTcpExchange ex = endpoint.createExchange();
>>            ex.setIn(msg);
>>            getProcessor().process(ex);
>>
>>
>> The consumer, component, endpoint and exchange all inherit from
>> default classes and don't do anything particularly interesting  (I can
>> send the code if that would help). What could be going on here? Many
>> thanks  - Ethan

Re: all messages go to dead letter channel

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Which version of Camel are you using?
Can you try the last released Camel 1.6.1 ?
I just check the latest code repository, we did some improvements on the
LogFormatter and you should not get ClassCastException here :).

Willem


Ethan Aubin wrote:
> Hi, I'm trying to write a camel component which reads a value from a
> socket and logs the results. I'm doing something wrong in the
> component or in the configuration of my route as the value always is
> delivered to the dead letter channel and fails with the following
> exception
> 
> SEVERE: Failed delivery for exchangeId:
> ID-eaubin-1/51474-1243953466200/1-3. On delivery attempt: 0 caught:
> java.lang.ClassCastException:
> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
> org.apache.camel.converter.stream.StreamCache
> java.lang.ClassCastException:
> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
> org.apache.camel.converter.stream.StreamCache
> at org.apache.camel.component.log.LogFormatter.getBodyAsString(LogFormatter.java:182)
> at org.apache.camel.component.log.LogFormatter.format(LogFormatter.java:74)
> at org.apache.camel.processor.Logger.logMessage(Logger.java:234)
> at org.apache.camel.processor.Logger.process(Logger.java:88)
> at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
> at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
> at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
> at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
> at java.lang.Thread.run(Thread.java:637)
> java.lang.NullPointerException
> at org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:49)
> at org.apache.camel.processor.DeadLetterChannel.incrementRedeliveryCounter(DeadLetterChannel.java:430)
> at org.apache.camel.processor.DeadLetterChannel.handleException(DeadLetterChannel.java:287)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:162)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
> at java.lang.Thread.run(Thread.java:637)
> 
> 
> Camel is started using
> 
>        context = new DefaultCamelContext(new JndiRegistry());
>        context.addComponent("xmltcp", new XmlTcpComponent(context));
>        ccEndpoint = context.getEndpoint("xmltcp://127.0.0.1:15001");
>        context.addRoutes(new RouteBuilder() {
>            @Override
>            public void configure() {
>                from(ccEndpoint).to("log:loggingCategoryFoo?level=INFO");
>            }
>        });
>        context.start();
> 
> After the value has been read from the socket the consumer delivers it with:
> 
>            DefaultMessage msg = new DefaultMessage();
>            msg.setBody(obj);
>            XmlTcpExchange ex = endpoint.createExchange();
>            ex.setIn(msg);
>            getProcessor().process(ex);
> 
> 
> The consumer, component, endpoint and exchange all inherit from
> default classes and don't do anything particularly interesting  (I can
> send the code if that would help). What could be going on here? Many
> thanks  - Ethan
> 


Re: all messages go to dead letter channel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You got a NPE exception at:

java.lang.NullPointerException
at org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:49)

I guess the problem is that you manually creates these message
objects. Some of them might need to have the CamelContext or some
parent object set as well. But check line 49 in this source file to
see what the NPE is.





On Tue, Jun 2, 2009 at 5:02 PM, Ethan Aubin <et...@gmail.com> wrote:
> Hi, I'm trying to write a camel component which reads a value from a
> socket and logs the results. I'm doing something wrong in the
> component or in the configuration of my route as the value always is
> delivered to the dead letter channel and fails with the following
> exception
>
> SEVERE: Failed delivery for exchangeId:
> ID-eaubin-1/51474-1243953466200/1-3. On delivery attempt: 0 caught:
> java.lang.ClassCastException:
> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
> org.apache.camel.converter.stream.StreamCache
> java.lang.ClassCastException:
> com.sun.org.apache.xerces.internal.dom.DocumentImpl cannot be cast to
> org.apache.camel.converter.stream.StreamCache
> at org.apache.camel.component.log.LogFormatter.getBodyAsString(LogFormatter.java:182)
> at org.apache.camel.component.log.LogFormatter.format(LogFormatter.java:74)
> at org.apache.camel.processor.Logger.logMessage(Logger.java:234)
> at org.apache.camel.processor.Logger.process(Logger.java:88)
> at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:92)
> at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:66)
> at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
> at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:84)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
> at java.lang.Thread.run(Thread.java:637)
> java.lang.NullPointerException
> at org.apache.camel.impl.DefaultMessage.getHeader(DefaultMessage.java:49)
> at org.apache.camel.processor.DeadLetterChannel.incrementRedeliveryCounter(DeadLetterChannel.java:430)
> at org.apache.camel.processor.DeadLetterChannel.handleException(DeadLetterChannel.java:287)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:162)
> at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.passDocument(XmlTcpConsumer.java:221)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.readDocument(XmlTcpConsumer.java:167)
> at edu.mit.ll.ncint.camel.XmlTcpConsumer$SocketProcessor.run(XmlTcpConsumer.java:201)
> at java.lang.Thread.run(Thread.java:637)
>
>
> Camel is started using
>
>        context = new DefaultCamelContext(new JndiRegistry());
>        context.addComponent("xmltcp", new XmlTcpComponent(context));
>        ccEndpoint = context.getEndpoint("xmltcp://127.0.0.1:15001");
>        context.addRoutes(new RouteBuilder() {
>            @Override
>            public void configure() {
>                from(ccEndpoint).to("log:loggingCategoryFoo?level=INFO");
>            }
>        });
>        context.start();
>
> After the value has been read from the socket the consumer delivers it with:
>
>           DefaultMessage msg = new DefaultMessage();
>            msg.setBody(obj);
>            XmlTcpExchange ex = endpoint.createExchange();
>            ex.setIn(msg);
>            getProcessor().process(ex);
>
>
> The consumer, component, endpoint and exchange all inherit from
> default classes and don't do anything particularly interesting  (I can
> send the code if that would help). What could be going on here? Many
> thanks  - Ethan
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus