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 <ethan.au...@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

Reply via email to