RepositoryService is a interface, and an object of interface can't be made. Try setting resource class as RepositoryServiceImpl. On 8 Feb 2015 15:54, "gido" <[email protected]> wrote:
> Dear All, > > I am trying to develop restful webservices. I have followed the tutorial: > > > http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/main/java/demo/jaxrs/server/Server.java?revision=1490431&view=markup > > Everything seems good, the Server is running. However, whenever I try to > create a client with the following code: > > JAXRSClientFactoryBean client = new JAXRSClientFactoryBean(); > > client.setAddress(" > http://localhost:9000/repositoryservice/datafromenvironment"); > client.setResourceClass(RepositoryService.class); > RepositoryService repos = client.create(RepositoryService.class); > > I have the following error: > > Exception in thread "main" java.lang.NoSuchMethodError: > > org.apache.cxf.common.util.ClassHelper.getRealClass(Lorg/apache/cxf/Bus;Ljava/lang/Object;)Ljava/lang/Class; > at > > org.apache.cxf.jaxrs.client.ClientProviderFactory.setProviders(ClientProviderFactory.java:91) > at > > org.apache.cxf.jaxrs.provider.ProviderFactory.initBaseFactory(ProviderFactory.java:138) > at > > org.apache.cxf.jaxrs.client.ClientProviderFactory.initBaseFactory(ClientProviderFactory.java:81) > at > > org.apache.cxf.jaxrs.client.ClientProviderFactory.createInstance(ClientProviderFactory.java:56) > at > > org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.initClient(JAXRSClientFactoryBean.java:377) > at > > org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXRSClientFactoryBean.java:321) > at > > org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFactoryBean.java:264) > at > pt.uninova.restfulservicetest.testeRestful.main(testeRestful.java:36) > > My classes are: > > @Path("/repositoryservice/") > public interface RepositoryService { > > @POST > @Path("/datafromenvironment/") > Response addDataFromEnvironment(Data data); > > @GET > @Path("/Hello/{name}") > String sayHello(@PathParam("name") String name); > > } > > and > > public class RepositoryServiceImpl implements RepositoryService{ > > private RepositoryImpl repos; > > public RepositoryServiceImpl() { > initializeService(); > } > > @Override > public Response addDataFromEnvironment(Data data) { > repos.openConnection(); > repos.Insert(data); > repos.closeConnection(); > return Response.ok(data).build(); > } > > @Override > public String sayHello(String name) { > return "hello " + name; > } > > private void initializeService(){ > this.repos = new RepositoryImpl(); > } > > } > > Do you have any suggestion? > > Thank you for the help. > > BR, > > Giovanni > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Restful-WS-problem-when-creating-a-client-tp5754027.html > Sent from the cxf-user mailing list archive at Nabble.com. >
