camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Korab <jakub.korab.li...@gmail.com>
Subject Re: com.sun.org.apache.xerces.internal.dom.TextImpl cannot be cast to java.lang.String
Date Fri, 24 Jul 2015 12:11:10 GMT
Try setting the return type from the xpath expression:

.setHeader("isbns", xpath("/order//isbn/text()", List.class))

Jakub

On 24/07/15 13:05, Markus Eisele wrote:
> Hi,
>
> I was trying to convert a bunch of //text() Nodes selected via XPath
> into a List<String> and keep getting a ClassCastException.
>
> My input xml:
>
>    <isbn>9781617290450</isbn>
>   <isbn>9780132360280</isbn>
>
> The route
>
> .setHeader("isbns", xpath("/order//isbn/text()"))
> .bean(orderService, "handleOrder(${header[isbns]})")
>
> The Bean Method:
>
> public void handleOrder(List<String> orders) {
>
>          orders.stream().forEach((o) -> {
>              LOGGER.log(Level.INFO, "Order: {0}", o);
>          });
>
>
> Thanks for a hint.
>
> Cheers,
> Markus


Mime
View raw message