[
https://issues.apache.org/jira/browse/CAMEL-4014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13541242#comment-13541242
]
Jason Chaffee commented on CAMEL-4014:
--------------------------------------
I just tried this on 2.10.3 and I still get the "Resource class interface
org.test.MyService has no valid constructor" error.
> cxf:rsServer requires class instead of interface in the serviceClass attribute
> ------------------------------------------------------------------------------
>
> Key: CAMEL-4014
> URL: https://issues.apache.org/jira/browse/CAMEL-4014
> Project: Camel
> Issue Type: Improvement
> Components: camel-cxf
> Affects Versions: 2.6.0, 2.7.0, 2.7.1
> Reporter: Sergey Zhemzhitsky
> Assignee: Willem Jiang
> Labels: camel, cxf, jaxrs
> Fix For: 2.9.3, 2.10.1, 2.11.0
>
>
> Here are part of the conversation from the mailing list:
> 1.
> Hi there,
> I'm using apache-servicemix-4.3.1-fuse-01-09 and I need to consume RESTful
> requests.
> Here is the documentation I have used: http://camel.apache.org/cxfrs.html
> Here is my configuration file
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> xmlns:cxf="http://camel.apache.org/schema/cxf"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd
> http://camel.apache.org/schema/cxf
> http://camel.apache.org/schema/cxf/camel-cxf.xsd
> ">
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"
> />
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
> <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
> <cxf:rsServer id="myServer" address="/" serviceClass="org.test.MyService"
> />
> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="cxfrs://bean:myServer?exchangePattern=InOut"/>
> <transform>
> <constant>Hello World!!!</constant>
> </transform>
> </route>
> </camelContext>
> </beans>
> Here is implementation of org.test.MyService
> @Path("/service")
> @Produces("application/json")
> public class MyService {
> @POST
> @Path("/resource")
> public Response add(@QueryParam("res") String res) {
> return Response.ok(new Status("The Resource has been
> processed")).build();
> }
> }
> I'm wondering why we have to specify the serviceClass attribute and why this
> attribute should point at the real class. I'm asking because the response of
> such a service will always be "Hello World!!!" and implementation of
> MyService.add method does not matter in that case.
> 2.
> Hi Ben,
> You are right, the serviceClass is just used to build up the JAXRS service
> module. And Camel CXF RS Consumer doesn't all serviceClass instance at the
> end, it just route the request to the camel route.
> 3.
> Hi Willem, Ben
> Thanks for the information.
> I tried to use the interface instead of class in the serviceClass attribute
> and I didn't succeed because of an exception that told that the class is
> required.
> Here is the exception:
> Caused by: java.lang.RuntimeException: Resource class interface
> org.test.MyService has no valid constructor
> at
> org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider.<init>(PerRequestResourceProvider.java:45)
> at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.updateClassResourceProviders(JAXRSServerFactoryBean.java:338)
> at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:119)
> ... 26 more
> I think that using an interface would be better in that case.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira