Hi How does a sample RestResourceHandler look ? Can you send it to me ? CXF 2.2.4 will say something useful about such errors...
Cheers, Sergey -----Original Message----- From: Pranab Verma [mailto:[email protected]] Sent: 31 August 2009 13:43 To: [email protected] Subject: Re: Trouble creating Proxy on the Client side using JAXRSClientFactory Hi Kiran/Sergey, I am facing the same issue while using JAXRSClientFactory. I have created a simple JAVA project. Here is the snippet : import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import com.my.rest.RestResourceHandler; public class ProxyClient { static public void main(String arg[]) { String baseAddress = "http://localhost:8443/network/"; RestResourceHandler proxy = JAXRSClientFactory.create(baseAddress, RestResourceHandler.class); } } The error message is : Creating proxy..Exception in thread "main" javax.ws.rs.WebApplicationException at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXR SClientFactoryBean.java:137) at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFac toryBean.java:113) at org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory .java:71) at org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory .java:56) at org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory .java:46) at ProxyClient.main(ProxyClient.java:13) I have added cglib-nodep-2.1_3.jar library in project properties settings but still am getting the same error. Kiran, Were you able to resolve the problem? Sergey, Am I doing the right thing? If not, please tell me what needs to be done? Thanks, Pranab Sergey Beryozkin wrote: > > Hi Kiran > > The error message is non-existent - I'll have to fix it. > I think you need to add a cglib-nodeps dependency given that you're > creating a proxy from a concrete class, it will fix it (will document it > as well if it's not documented yet) > > cheers, Sergey > > kiran.sidhu wrote: >> >> Hi, >> >> I am getting a WebApplicationException when I try to >> create a proxy using JAXRSClientFactory, I tried both create API and >> fromClient API. >> >> The WebClient API works fine. >> >> >> >> Here is my Client code : >> >> >> >> WebClient wc = >> WebClient.create("http://localhost:8080/cxf-webservices/webservices/cust >> omerservice/"); >> >> >> wc.accept("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0 >> .8"); >> >> wc.encoding("UTF-8"); >> >> wc.header("accept-charset", >> "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); >> >> >> >> >> >> CustomerService proxy = JAXRSClientFactory.create( >> "http://localhost:8080/cxf-webservices/webservices/customerservice/",Cus >> tomerService.class); >> >> List<Customer> ccoll = proxy.getCustomers(); >> >> >> >> Right at the create statement, I get the following exception : >> >> >> >> javax.ws.rs.WebApplicationException >> >> at >> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXR >> SClientFactoryBean.java:149) >> >> at >> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFac >> toryBean.java:118) >> >> at >> org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory >> .java:71) >> >> at >> org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory >> .java:56) >> >> at >> org.apache.cxf.jaxrs.client.JAXRSClientFactory.create(JAXRSClientFactory >> .java:46) >> >> at com.asipay.ws.client.Client.main(Client.java:82) >> >> >> >> Here is my Service class : >> >> @Path("/customerservice/") >> >> public class CustomerService { >> >> >> >> private Map<Integer, Customer> customerMap = new TreeMap<Integer, >> Customer>(); >> >> public CustomerService() { >> >> //Hard coded for testing >> >> Customer customer = new Customer(); >> >> customer.setId(0); >> >> customer.setName("Jane Doe"); >> >> customer.setAddress("123 Howe Ave, Los Angeles, CA"); >> >> addCustomer(customer); >> >> } >> >> >> >> @GET >> >> @Path("/customers") >> >> @Produces("application/xml") >> >> //@Resource MessageContext jaxrsContext; >> >> public List<Customer> getCustomers() { >> >> //return new Customers(customerMap.values()); >> >> return new ArrayList<Customer>(customerMap.values()); >> >> } >> >> >> >> @GET >> >> @Path("/customers/{id}") >> >> @Produces("text/xml") >> >> public Customer getCustomer(@PathParam("id") int cId) { >> >> >> >> return customerMap.get(cId); >> >> } >> >> >> >> @PUT >> >> @Consumes("application/xml") >> >> @Produces("text/plain") >> >> @Path("/customers/update/{id}") >> >> public String updateCustomer(@PathParam("id") Long id, Customer >> customer) { >> >> customerMap.put(id.intValue(), customer); >> >> return "Customer " + customer.getName() + " updated. Id = >> " + id; >> >> } >> >> >> >> @POST >> >> @Path("/customers/add") >> >> @Produces("text/plain") >> >> @Consumes("application/xml") >> >> public String addCustomer(Customer customer) { >> >> int id = customerMap.size(); >> >> customer.setId(id); >> >> customerMap.put(id, customer); >> >> return "Customer " + customer.getName() + " added with Id " + >> id; >> >> } >> >> >> >> @DELETE >> >> @Path("/customers/delete/{id}") >> >> @Produces("text/plain") >> >> @Consumes("application/xml") >> >> public String deleteCustomer(@PathParam("id") Integer id) { >> >> >> >> Customer customer = customerMap.get(id); >> >> customerMap.remove(id); >> >> return "Customer " + customer.getName() + " removed with Id " >> + id; >> >> } >> >> >> >> Any idea if I am missing something ? >> >> >> >> Thanks >> >> Kiran >> >> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ >> _ >> >> Notice: This information is intended only for the person(s) or >> entity(ies) to which it is addressed. This information may contain >> information that is confidential or otherwise protected from disclosure. >> If you are not the intended recipient of this message, or if this message >> has been addressed to you in error, please immediately alert the sender >> by reply e-mail and then delete this message, including any attachments. >> Any dissemination, distribution or other use of the contents of this >> message by anyone other than the intended recipient is strictly >> prohibited. >> >> > > -- View this message in context: http://www.nabble.com/Trouble-creating-Proxy-on-the-Client-side-using-JA XRSClientFactory-tp24960821p25222877.html Sent from the cxf-user mailing list archive at Nabble.com.
