TypeConversion例外:Apache的骆驼和CXF [英] TypeConversion Exception : Apache Camel and CXF
问题描述
我试图与Apache集成骆驼CXF RESTful Web服务。我得到了以下异常,当我请求发送到我的web服务:
产生的原因:org.apache.camel.NoTypeConversionAvailableException:没有可用的类型转换器从类型转换:org.apache.cxf.message.MessageContentsList到所需的类型:java.io. InputStream的值为[空]
在org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:147)
在org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)
... 68更多
我贴我的配置XML的部分进行审核:
< JAXRS:服务器ID =restContainer地址=/staticSubresourceResolution =真>< JAXRS:serviceBeans>
<参考豆=FooBar的/>
< / JAXRS:serviceBeans>< JAXRS:供应商>
< bean类=org.apache.cxf.jaxrs.provider.JSONProvider>
<属性名=dropRootElementVALUE =真/>
<属性名=supportUnwrappedVALUE =真/>
< / JAXRS:供应商>< camelcxf:rsServer ID =rsServer地址=HTTP://本地主机:端口/为MyApplication / REST / foobar的serviceClass =com.camel.example.FooBar/><骆驼:camelContext ID =camelContext-1>
<骆驼:路线>
<骆驼:从URI =cxfrs:豆:rsServer/>
<骆驼:到URI =http://www.google.com/>
< /骆驼:路线>
< /骆驼:camelContext>
解决..其实问题并没有当我的CXF服务器击中了所有的错误,它出来是当交换是在为部分...
我不得不往返之间增加一个处理器,并覆盖所有CamelHttpUri,CamelHttpMethod等....,使其工作。
< camelcxf:rsServer ID =rsServer地址=HTTP://本地主机:端口/为MyApplication / REST / foobar的serviceClass =com.camel.example.FooBar/ ><骆驼:camelContext ID =camelContext-1><骆驼:路线>
<骆驼:从URI =cxfrs:豆:rsServer/>
<骆驼:过程REF =customInProcessor/>
<骆驼:到URI =http://www.google.com/>
< /骆驼:路线>
< /骆驼:camelContext><豆的id =customInProcessor级=com.camel.MyInProcessor/>
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>
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" />
这篇关于TypeConversion例外:Apache的骆驼和CXF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!