camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: How to save a select result from camel-sql componnent to xml ( No type converter available to convert from type: java.util.ArrayList issue )
Date Fri, 16 Oct 2009 15:39:36 GMT
On Fri, Oct 16, 2009 at 5:24 PM, llecaroz <> wrote:
> Hello,
> I am really impresed by the capabilities of Apache Camel.
> I am creating a workflow with a similar route
>                        <camel:setBody><camel:constant>1</camel:constant></camel:setBody>
>                                <camel:to uri="sql:select * from rule
where ruleId = # order by
> ruleId?dataSourceRef=myDataSource"/>
>                                <camel:setHeader headerName="CamelFileName">
>                                        <camel:constant>out.txt</camel:constant>
>                                </camel:setHeader>
>                        <camel:to uri="file://target/data"/>
> It works great until trying to save select result :(
> because it is an arralist returned, it appears that Apache Camel does not
> have any convert type :(
> I tried also to use jaxb mashall or convertBodyto to convert it before into
> a xml format, but without any success, so I don't know what to do with the
> result without writing a pojo consumer !?
> I spent multiple hours on Internet to search for tutorials or other apache
> camel users encountering the same need behavior but no answer :(

You can use Java code to transform the payload into a more appropriate format.

You can use a org.apache.camel.Processor or POJO

                        <camel:processRef ref="myTransformProcessor"/>
                        <camel:to uri="file://target/data"/>

<bean id="myTransformProcessor" class="com.mycompany.MyTransformProcessor"/>

public class MyTransformProcessor implements Processor {
  List data = exchange.getIn().getBody(List.class);
   // use regular java code to transform to a better form

See more at the Message Translator EIP

The SQL component returns raw data in a List that is like the sql ResultSet.
You gotta transform that manually to something else using Java code.

Or use some ORM that can map from the database to POJO classes which
are easier to marshal to XML using camel-xstream or JAXB annotations

> Expert help on my question would be appreciate ;)
> Really thx in advance
> Regards
> Louis
> Caused by: org.apache.camel.InvalidPayloadException: No body available of
> type: but has value: [{ruleId=1, syncDir=/essai/1}] of
> type: java.util.ArrayList on: Message: [{ruleId=1, syncDir=/essai/1}].
> Caused by: No type converter available to convert from type:
> java.util.ArrayList to the required type: with value
> [{ruleId=1, syncDir=/essai/1}] on the exchange: Exchange[Message:
> [{ruleId=1, syncDir=/essai/1}]]
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:

View raw message