You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Henrique Viecili <he...@myreks.com> on 2012/06/27 18:37:56 UTC

JAXB marshal generates byte[] array instead of String

Dear Camel Breeders,

would you know any reason why after marshaling an object with jaxb data
format the result BodyType is a byte[] array instead of java.lang.String?

With byte[] I see conversion problems as the log below shows:
12:45:42,474 | WARN  | onsumer-thread-5 | JbiBinding
| ?                                   ? | 196 - servicemix-camel -
2011.02.1.fuse-02-13 | Unable to convert message body of type class [B into
an XML Source

I know I can solve it by using <convertBodyTo>, but I don't believe this is
a good practice.

BTW, I am using camel 2.8.0.fuse-01-13 with SMX 4.4.1-fuse-01-13, and there
is nothing special in my data format configuration: <camel:jaxb
id="JAXB-com.bean.jaxb" prettyPrint="true" contextPath="com.bean.jaxb" />

att.
*Henrique Viecili*

Re: JAXB marshal generates byte[] array instead of String

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

I logged a ticket
https://issues.apache.org/jira/browse/CAMEL-6316

On Mon, Apr 22, 2013 at 8:55 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Fell free to log a ticket for such an improvement. And as usual
> patches is welcome.
>
>
> On Sat, Apr 20, 2013 at 5:00 PM, j_h_scheufen
> <ja...@sungard.com> wrote:
>> I just discovered the same thing. Using <marshal> with a jaxb data format
>> produces a byte[] which was not really expected, because the typical use
>> case <unmarshal> is to have a java.lang.String as input.
>>
>> I understand that downstream endpoints which expect a java.lang.String can
>> benefit from Camel's automatic conversion, but if the invoker of the route
>> expected to get the XML back as a String, you always have to remember to add
>> <convertBodyTo ...>. You'd wish the jaxb data format had a property to
>> control the output ...
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/JAXB-marshal-generates-byte-array-instead-of-String-tp5715174p5731170.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB marshal generates byte[] array instead of String

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

Fell free to log a ticket for such an improvement. And as usual
patches is welcome.


On Sat, Apr 20, 2013 at 5:00 PM, j_h_scheufen
<ja...@sungard.com> wrote:
> I just discovered the same thing. Using <marshal> with a jaxb data format
> produces a byte[] which was not really expected, because the typical use
> case <unmarshal> is to have a java.lang.String as input.
>
> I understand that downstream endpoints which expect a java.lang.String can
> benefit from Camel's automatic conversion, but if the invoker of the route
> expected to get the XML back as a String, you always have to remember to add
> <convertBodyTo ...>. You'd wish the jaxb data format had a property to
> control the output ...
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JAXB-marshal-generates-byte-array-instead-of-String-tp5715174p5731170.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB marshal generates byte[] array instead of String

Posted by j_h_scheufen <ja...@sungard.com>.
I just discovered the same thing. Using <marshal> with a jaxb data format
produces a byte[] which was not really expected, because the typical use
case <unmarshal> is to have a java.lang.String as input.

I understand that downstream endpoints which expect a java.lang.String can
benefit from Camel's automatic conversion, but if the invoker of the route
expected to get the XML back as a String, you always have to remember to add
<convertBodyTo ...>. You'd wish the jaxb data format had a property to
control the output ...



--
View this message in context: http://camel.465427.n5.nabble.com/JAXB-marshal-generates-byte-array-instead-of-String-tp5715174p5731170.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JAXB marshal generates byte[] array instead of String

Posted by Henrique Viecili <he...@myreks.com>.
Please disregard the comment about conversion issue, a simple refresh on
camel-jaxb in servicemix solved the problem.

BUT, the result of marshal is still a byte[] array while I believe it
should be java.lang.String.

att.
*Henrique Viecili*


On Wed, Jun 27, 2012 at 1:37 PM, Henrique Viecili <he...@myreks.com>wrote:

> Dear Camel Breeders,
>
> would you know any reason why after marshaling an object with jaxb data
> format the result BodyType is a byte[] array instead of java.lang.String?
>
> With byte[] I see conversion problems as the log below shows:
> 12:45:42,474 | WARN  | onsumer-thread-5 | JbiBinding
> | ?                                   ? | 196 - servicemix-camel -
> 2011.02.1.fuse-02-13 | Unable to convert message body of type class [B into
> an XML Source
>
> I know I can solve it by using <convertBodyTo>, but I don't believe this
> is a good practice.
>
> BTW, I am using camel 2.8.0.fuse-01-13 with SMX 4.4.1-fuse-01-13, and
> there is nothing special in my data format configuration: <camel:jaxb
> id="JAXB-com.bean.jaxb" prettyPrint="true" contextPath="com.bean.jaxb" />
>
> att.
> *Henrique Viecili*
>
>
>