Question

I have a camel route with a cxf producer (Camel v2.10):

<to uri="cxf:bean:myCxfEndpoint?dataFormat=PAYLOAD"/>

I know that camel does a conversion to CxfPayload, so I added the following imports to OSGi header:

org.apache.camel.component.cxf,
org.apache.camel.component.cxf.converter,
org.apache.camel.converter.jaxb

So when the producer is triggered the following exception occurs:

org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: my.package.Foo to the required type: org.apache.camel.component.cxf.CxfPayload

I can get rid of this exception by restarting the camel-jaxb bundle, but getting rid of it is not enough: I need to prevent it, because it happens every time I restart Fuse.

Any idea is highly appreciated :)

EDIT

It turned out that the issue doesn't always come up. Sometimes it works after restart, sometimes it doesn't. I tried to play with bundle-levels but it remained unpredictable. I have a feeling that it might be Camel who doesn't load the converters correctly, but based on the trace log it looks like the CxfPayloadConverter is always loaded into the ConverterRegistry.

Was it helpful?

Solution

After 10 hours of tracing and debugging I figured out the solution: I added a manual marshalling before the CXF Producer, like this:

    <marshal ref="myDataFormat"/>
    <to uri="cxf:bean:myCxfEndpoint?dataFormat=PAYLOAD"/>

Why: My assumption was that it's OK to send any POJO to the Camel CXF Endpoint and it'll be able to handle the Conversion. The only thing I can think of is it matters that in what order Camel loads the Converters. Every second time when it worked in fuse it could make a POJO -> String -> CxfPayload conversion so it could transitively resolve the conversion. I decided not to rely on this transitive conversion logic and checked all the loaded converters. I found that there are certain direct converters registered in the registry between XML Node/Element -> CxfPayload classes. So I decided to trick Camel's logic with marshalling my POJO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top