You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hoboy <lu...@yahoo.com> on 2016/02/19 10:38:06 UTC
InvalidPayloadException: No body available
I have the following 2 files.
Jax-rs
@ApplicationPath("Test")
public class ApplicationActivator extends Application {
}
and the resource class
@Path("test")
public class MyResource {
@Context
UriInfo uri;
@Context
HttpHeaders headers;
@GET
@Path("/getResource")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getResource(@Context Request req) {
lots of codes here
}
So far so good.
I have created a maven camel-spring-dm project.
I want to create a camel service that can be access from browser.. a url.
------------------------------------------------------------------------------------------------------------------------
Here is part of the camel context file
<bean id="TesponseTransformer"
class="com.test.camel.spring.dm.TestResponseTransformer"/>
<bean id="ApplicationActivator"
class="com.test.camel.spring.dm.ApplicationActivator" />
<bean id="serviceClass" class="com.test.camel.spring.dm.MyResource" />
<cxf:rsServer id="endpoint" address="http://localhost:9090">
<cxf:serviceBeans>
<ref bean="serviceClass" />
</cxf:serviceBeans>
</cxf:rsServer>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxfrs:bean:endpoint" />
<log message="Befor calling service, the message is ${body}" />
<to uri="direct:serviceClass" />
</route>
<route>
<from uri="direct:serviceClass" />
<bean ref="TesponseTransformer" method="ReponseMapper" />
<log message="After calling service, the message is ${body}" />
</route>
</camelContext>
----------------------------------------------------------------------------------------------------------------------
The question how does should look like ?
public class TestResponseTransformer {
public void ReponseMapper(@Body Response request, Exchange exchange){
}
}
------------------------------------------------------------------------------------------------------------------------
I don't want to over crowded this email.
In my current implementation i am getting this errors and more.
Caused by: org.apache.camel.InvalidPayloadException: No body available of
type: javax.ws.rs.core.Response but has value:
[org.apache.cxf.jaxrs.impl.RequestImpl@7f462455] of type:
org.apache.cxf.message.MessageContentsList on: Message:
[org.apache.cxf.jaxrs.impl.RequestImpl@7f462455]. Caused by: No type
converter available to convert from type:
org.apache.cxf.message.MessageContentsList to the required type:
javax.ws.rs.core.Response with value
[org.apache.cxf.jaxrs.impl.RequestImpl@7f462455].
Exchange[ID-test-39629-1455872639435-0-2][Message:
[org.apache.cxf.jaxrs.impl.RequestImpl@7f462455]]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: org.apache.cxf.message.MessageContentsList
to the required type: javax.ws.rs.core.Response with value
[org.apache.cxf.jaxrs.impl.RequestImpl@7f462455]]
at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)[226:org.apache.camel.camel-core:2.16.1.redhat-630015]
----------------------------------------------------------------------------------------------------------------------
Tks in advance
--
View this message in context: http://camel.465427.n5.nabble.com/InvalidPayloadException-No-body-available-tp5777906.html
Sent from the Camel - Users mailing list archive at Nabble.com.