Sikorski
Sikorski

Reputation: 2691

TypeConversion Exception : Apache Camel and CXF

I am trying to integrate CXF restful web services with Apache Camel. I am getting the following exception when I send a request to my web service:

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: java.io.InputStream with value [null]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:147)
    at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)
    ... 68 more

I am pasting a section of my config xml for review:

<jaxrs:server id="restContainer" address="/" staticSubresourceResolution="true">

<jaxrs:serviceBeans>
    <ref bean="FooBar"/>
</jaxrs:serviceBeans>

<jaxrs:providers>
    <bean class="org.apache.cxf.jaxrs.provider.JSONProvider">
    <property name="dropRootElement" value="true"/>
    <property name="supportUnwrapped" value="true"/>
</jaxrs:providers>

<camelcxf:rsServer id="rsServer" address="http://localhost:port/MyApplication/rest/foobar" serviceClass="com.camel.example.FooBar"/>

<camel:camelContext id="camelContext-1">
    <camel:route>
        <camel:from uri="cxfrs:bean:rsServer"/>
        <camel:to uri="http://www.google.com"/>
    </camel:route>
</camel:camelContext> 

Upvotes: 0

Views: 10337

Answers (1)

Sikorski
Sikorski

Reputation: 2691

solved all the errors.. actually the problem was not when my cxf server was getting hit, it comes out to be when the exchange was in the "to" part... i had to add a processor in between from and to and override all the CamelHttpUri , CamelHttpMethod etc .... to make it work.

<camelcxf:rsServer id="rsServer" address="http://localhost:port/MyApplication/rest/foobar serviceClass="com.camel.example.FooBar" />  <camel:camelContext id="camelContext-1">  <camel:route>  
<camel:from uri="cxfrs:bean:rsServer" />  
<camel:process ref="customInProcessor" />
<camel:to uri="http://www.google.com" /> 
 </camel:route>
  </camel:camelContext> 

<bean id="customInProcessor" class="com.camel.MyInProcessor" />

Upvotes: 2

Related Questions