You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alp Timurhan Çevik <at...@gmail.com> on 2011/06/16 18:04:22 UTC

Trouble with convertbodyto

urgent help needed :)

I am experiencing this very weird behaviour regarding convertbodyto.

I am using xsl to transform some legacy web service calls through cxf
component (payload) and transforming them using xsl such as:

<camel:route id="...">
            <camel:from ref="v1" />
            <convertBodyTo type="java.lang.String" />
            <camel:to uri="file://first.log"/>
            <camel:to uri="xslt://a.xsl" />
            <camel:to ref="v2" />
            <camel:to uri="b.xsl" />
        </camel:route>

this worked quite well in eclipse, but after having it built with hudson
using maven, the same route produced content not allowed in prolog message.
Looking at the first.log files, I noticed the working one has
<anyxmltag>sdlkjlkj</anyxmltag>

whereas the maven built one has

org.apache.camel.component.cxf.CxfPayload headers: []body: [ [

prior to <anyxmltag>sdlkjlkj</anyxmltag>

which I think is causing the problem.

What could be the problem ? old dependencies etc. ? xml configuration files
? Any idea ?

Thanks a lot,
Alp

Re: Trouble with convertbodyto

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

See also the FAQ
http://camel.apache.org/how-do-i-use-a-big-uber-jar.html

2011/6/16 Alp Timurhan Çevik <at...@gmail.com>:
> Found the problem...
>
> We are using maven shade plugin to get a fat jar. During fat jar generation,
> the files within the META-INF are overriden by the same named files, one of
> which is TypeConverter.
>
> The camel-core TypeConverter overrides the camel-cxf type converter, and
>
> org.apache.camel.converter
>
> org.apache.camel.component.bean
>
> org.apache.camel.component.file
>
> including one overrides the
>
> org.apache.camel.component.cxf.converter
>
> one.
>
> The result was, instead of using cxf typeconverters, camel was using
> standart simple string converter, which converts using to string method,
> producing an invalid xml. Introducing the cxf ones back solved the problem.
>
>
> So combining them together
>
>
> org.apache.camel.converter
> org.apache.camel.component.bean
> org.apache.camel.component.file
> org.apache.camel.component.cxf.converter
>
> within the META-INF/services/org/apache/camel/TypeConverter did the trick.
> Could be done manually, but the best way is using transformers within the
> shade artifact such as
>
> <transformer
> implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
> <resource>META-INF/services/org/apache/camel/TypeConverter</resource>
> </transformer>
>
> Best wishes,
> Alp
>
>
> 2011/6/16 Alp Timurhan Çevik <at...@gmail.com>
>
>> urgent help needed :)
>>
>> I am experiencing this very weird behaviour regarding convertbodyto.
>>
>> I am using xsl to transform some legacy web service calls through cxf
>> component (payload) and transforming them using xsl such as:
>>
>> <camel:route id="...">
>>             <camel:from ref="v1" />
>>             <convertBodyTo type="java.lang.String" />
>>             <camel:to uri="file://first.log"/>
>>             <camel:to uri="xslt://a.xsl" />
>>             <camel:to ref="v2" />
>>             <camel:to uri="b.xsl" />
>>         </camel:route>
>>
>> this worked quite well in eclipse, but after having it built with hudson
>> using maven, the same route produced content not allowed in prolog message.
>> Looking at the first.log files, I noticed the working one has
>> <anyxmltag>sdlkjlkj</anyxmltag>
>>
>> whereas the maven built one has
>>
>> org.apache.camel.component.cxf.CxfPayload headers: []body: [ [
>>
>> prior to <anyxmltag>sdlkjlkj</anyxmltag>
>>
>> which I think is causing the problem.
>>
>> What could be the problem ? old dependencies etc. ? xml configuration files
>> ? Any idea ?
>>
>> Thanks a lot,
>> Alp
>>
>>
>>
>>
>>
>>
>>
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Trouble with convertbodyto

Posted by Alp Timurhan Çevik <at...@gmail.com>.
Found the problem...

We are using maven shade plugin to get a fat jar. During fat jar generation,
the files within the META-INF are overriden by the same named files, one of
which is TypeConverter.

The camel-core TypeConverter overrides the camel-cxf type converter, and

org.apache.camel.converter

org.apache.camel.component.bean

org.apache.camel.component.file

including one overrides the

org.apache.camel.component.cxf.converter

one.

The result was, instead of using cxf typeconverters, camel was using
standart simple string converter, which converts using to string method,
producing an invalid xml. Introducing the cxf ones back solved the problem.


So combining them together


org.apache.camel.converter
org.apache.camel.component.bean
org.apache.camel.component.file
org.apache.camel.component.cxf.converter

within the META-INF/services/org/apache/camel/TypeConverter did the trick.
Could be done manually, but the best way is using transformers within the
shade artifact such as

<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/org/apache/camel/TypeConverter</resource>
</transformer>

Best wishes,
Alp


2011/6/16 Alp Timurhan Çevik <at...@gmail.com>

> urgent help needed :)
>
> I am experiencing this very weird behaviour regarding convertbodyto.
>
> I am using xsl to transform some legacy web service calls through cxf
> component (payload) and transforming them using xsl such as:
>
> <camel:route id="...">
>             <camel:from ref="v1" />
>             <convertBodyTo type="java.lang.String" />
>             <camel:to uri="file://first.log"/>
>             <camel:to uri="xslt://a.xsl" />
>             <camel:to ref="v2" />
>             <camel:to uri="b.xsl" />
>         </camel:route>
>
> this worked quite well in eclipse, but after having it built with hudson
> using maven, the same route produced content not allowed in prolog message.
> Looking at the first.log files, I noticed the working one has
> <anyxmltag>sdlkjlkj</anyxmltag>
>
> whereas the maven built one has
>
> org.apache.camel.component.cxf.CxfPayload headers: []body: [ [
>
> prior to <anyxmltag>sdlkjlkj</anyxmltag>
>
> which I think is causing the problem.
>
> What could be the problem ? old dependencies etc. ? xml configuration files
> ? Any idea ?
>
> Thanks a lot,
> Alp
>
>
>
>
>
>
>
>

Re: Trouble with convertbodyto

Posted by Willem Jiang <wi...@gmail.com>.
It looks the default CxfPayload toString() is used.
You may need to check if the CxfConverter is loaded rightly.

On 6/17/11 12:04 AM, Alp Timurhan Çevik wrote:
> urgent help needed :)
>
> I am experiencing this very weird behaviour regarding convertbodyto.
>
> I am using xsl to transform some legacy web service calls through cxf
> component (payload) and transforming them using xsl such as:
>
> <camel:route id="...">
>              <camel:from ref="v1" />
>              <convertBodyTo type="java.lang.String" />
>              <camel:to uri="file://first.log"/>
>              <camel:to uri="xslt://a.xsl" />
>              <camel:to ref="v2" />
>              <camel:to uri="b.xsl" />
>          </camel:route>
>
> this worked quite well in eclipse, but after having it built with hudson
> using maven, the same route produced content not allowed in prolog message.
> Looking at the first.log files, I noticed the working one has
> <anyxmltag>sdlkjlkj</anyxmltag>
>
> whereas the maven built one has
>
> org.apache.camel.component.cxf.CxfPayload headers: []body: [ [
>
> prior to<anyxmltag>sdlkjlkj</anyxmltag>
>
> which I think is causing the problem.
>
> What could be the problem ? old dependencies etc. ? xml configuration files
> ? Any idea ?
>
> Thanks a lot,
> Alp
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang