InvalidPayloadException

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

InvalidPayloadException

jpcook01
Hi,

I am getting this error when trying to consume and write a simple text message to file:

15234 [DefaultMessageListenerContainer-15] ERROR org.apache.camel.processor.DeadLetterChannel  - On delivery attempt: 0 caught: org.apache.camel.InvalidPayloadException: No in body available of type: java.io.InputStream but has value: Hello World of type: java.lang.String on the exchange: Exchange[FileMessage: target]

I thought I might be able to use convertBodyTo(InputStream.class) but that doesn't seem to help

Any help would be much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: InvalidPayloadException

jstrachan
On 17/10/2007, jpcook <[hidden email]> wrote:

>
> Hi,
>
> I am getting this error when trying to consume and write a simple text
> message to file:
>
> 15234 [DefaultMessageListenerContainer-15] ERROR
> org.apache.camel.processor.DeadLetterChannel  - On delivery attempt: 0
> caught: org.apache.camel.InvalidPayloadException: No in body available of
> type: java.io.InputStream but has value: Hello World of type:
> java.lang.String on the exchange: Exchange[FileMessage: target]
>
> I thought I might be able to use convertBodyTo(InputStream.class) but that
> doesn't seem to help
>
> Any help would be much appreciated.

It sounds like a message doesn't have a body in it. Do you have an
example of the Java code you were using to reproduce this?

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: InvalidPayloadException

jpcook01
Sure. It is quite simple.

public static void main(String args[]) throws Exception {
        BasicConfigurator.configure();
        log = Logger.getLogger(Main.class);
       
        CamelContext context = new DefaultCamelContext();

         context.addComponent("activemq",
                ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));

         context.addRoutes(new RouteBuilder() {
       
            @Override
            public void configure() {
            from("activemq:test.queue")
                    .to("file://target");
       
        CamelTemplate template = new CamelTemplate(context);
        context.start();
}

I'm running activemq 4.1 in a separate window and then using JConsole to submit a message to the test-queue queue.

The message is consumed OK:
7203 [DefaultMessageListenerContainer-7] DEBUG org.springframework.jms.listener.DefaultMessageListenerContainer  - Received message of type [class org.apache.activemq.command.ActiveMQTextMessage] from consumer [ActiveMQMessageConsumer { value=ID:nol12791-3917-1192629082991-1:0:1:1, started=true }] of session [ActiveMQSession {id=ID:nol12791-3917-1192629082991-1:0:1,started=true}]

I wondered if it was a problem outputting it to the file.

Jonathan

James.Strachan wrote
On 17/10/2007, jpcook <jonathan.cook@erars.plus.com> wrote:
>
> Hi,
>
> I am getting this error when trying to consume and write a simple text
> message to file:
>
> 15234 [DefaultMessageListenerContainer-15] ERROR
> org.apache.camel.processor.DeadLetterChannel  - On delivery attempt: 0
> caught: org.apache.camel.InvalidPayloadException: No in body available of
> type: java.io.InputStream but has value: Hello World of type:
> java.lang.String on the exchange: Exchange[FileMessage: target]
>
> I thought I might be able to use convertBodyTo(InputStream.class) but that
> doesn't seem to help
>
> Any help would be much appreciated.

It sounds like a message doesn't have a body in it. Do you have an
example of the Java code you were using to reproduce this?

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: InvalidPayloadException

jpcook01
I missed out:
});
jpcook wrote
Sure. It is quite simple.

public static void main(String args[]) throws Exception {
        BasicConfigurator.configure();
        log = Logger.getLogger(Main.class);
       
        CamelContext context = new DefaultCamelContext();

         context.addComponent("activemq",
                ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));

         context.addRoutes(new RouteBuilder() {
       
            @Override
            public void configure() {
            from("activemq:test.queue")
                    .to("file://target");
       
        CamelTemplate template = new CamelTemplate(context);
        context.start();
}

I'm running activemq 4.1 in a separate window and then using JConsole to submit a message to the test-queue queue.

The message is consumed OK:
7203 [DefaultMessageListenerContainer-7] DEBUG org.springframework.jms.listener.DefaultMessageListenerContainer  - Received message of type [class org.apache.activemq.command.ActiveMQTextMessage] from consumer [ActiveMQMessageConsumer { value=ID:nol12791-3917-1192629082991-1:0:1:1, started=true }] of session [ActiveMQSession {id=ID:nol12791-3917-1192629082991-1:0:1,started=true}]

I wondered if it was a problem outputting it to the file.

Jonathan

James.Strachan wrote
On 17/10/2007, jpcook <jonathan.cook@erars.plus.com> wrote:
>
> Hi,
>
> I am getting this error when trying to consume and write a simple text
> message to file:
>
> 15234 [DefaultMessageListenerContainer-15] ERROR
> org.apache.camel.processor.DeadLetterChannel  - On delivery attempt: 0
> caught: org.apache.camel.InvalidPayloadException: No in body available of
> type: java.io.InputStream but has value: Hello World of type:
> java.lang.String on the exchange: Exchange[FileMessage: target]
>
> I thought I might be able to use convertBodyTo(InputStream.class) but that
> doesn't seem to help
>
> Any help would be much appreciated.

It sounds like a message doesn't have a body in it. Do you have an
example of the Java code you were using to reproduce this?

--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: InvalidPayloadException

Arjan Moraal
In reply to this post by jpcook01
jpcook wrote
I wondered if it was a problem outputting it to the file.

Jonathan

James.Strachan wrote
It sounds like a message doesn't have a body in it. Do you have an
example of the Java code you were using to reproduce this?
When using an xslt transformation instead of writing to file directly, I get a similar error. It looks like it has something to do with reading the body of the message indeed.

Could not extract IN message body as type: interface javax.xml.transform.Source body is: <?xml version="1.0" encoding="UTF-8"?>
<rugbyFixtures>
  <rugbyFixture id="2909509" venue="Parc des Princes" date="2007-10-19" time="20:00:00">
    <homeTeam id="33176" name="France"/>
    <awayTeam id="33085" name="Argentina"/>
    <competition id="700" name="World Cup"/>
  </rugbyFixture>
</rugbyFixtures>
        at org.apache.camel.builder.xml.XsltBuilder.getSource(XsltBuilder.java:204)
        at org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:74)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsynProcessorBridge.process(AsyncProcessorTypeConverter.java:44)

However, when replacing apache-camel.jar by just camel-core, camel-jms, camel-spring and camel-juel it works. So is something from one of the other camel-* modules that is in apache-camel.jar getting in the way? Maybe some discovery algorithm picks up the wrong class?

I'm using the latest Camel sources from svn.