Hello, Le 23/05/2011 23:19, [email protected] a écrit : > Hi, > I have a very simple jaxrs application, having the resource class > containing a method returning a JSONObject. However on the client side I > am trying to print the returning while calling the get (see below) > > Client side: > ClientResource cr = new > ClientResource("http://localhost:8182/service"); > cr.getConverterService().setEnabled(true); > > cr.get(MediaType.APPLICATION_JSON).write(System.out); I think what happen is, with this line, you read the stream and exhaust it. After that, you can not read it again from the client resource. I hope I don't mislead you. Regards, Laurent. > > cr.get(ServiceResourceImpl.class).getServiceDescription(); > String jo = > cr.get(ServiceResourceImpl.class).getServiceDescription(); > > The last two methods return the following errors: > > WARNING: Unable to find a converter for this representation : > [application/json,UTF-8] > Exception in thread "main" java.lang.NullPointerException > at eu.emi.core.Client.main(Client.java:23) > > and > > WARNING: Unable to find a converter for this representation : > [application/json,UTF-8] > Exception in thread "main" java.lang.NullPointerException > at eu.emi.core.Client.main(Client.java:23) > > respectively (its the same)! > > Strangely the first one with ...write(System.out) works fine. > > On the server side, the resource method is being called without any > problems. > > Here is the resource class: > > @Path("/service") > public class ServiceResourceImpl{ > > /* (non-Javadoc) > * @see eu.emi.ServiceResource#getServiceDescription(java.lang.String) > */ > @GET > @Produces(MediaType.APPLICATION_JSON) > public JSONObject getServiceDescription() { > System.out.println("getting service description"); > Map<String, String> map = new HashMap<String, String>(); > map.put("id", "1"); > map.put("name", "data"); > > return new JSONObject(map); > } > } > > Could you please how can I resolve this? > > Thanks in advance, > Daku > > > CONFIDENTIALITY NOTICE: This e-mail and any files attached may contain > confidential and proprietary information of Alcatel-Lucent and/or its > affiliated entities. Access by the intended recipient only is > authorized. Any liability arising from any party acting, or refraining > from acting, on any information contained in this e-mail is hereby > excluded. If you are not the intended recipient, please notify the > sender immediately, destroy the original transmission and its > attachments and do not disclose the contents to any other person, use it > for any purpose, or store or copy the information in any medium. > Copyright in this e-mail and any attachments belongs to Alcatel-Lucent > and/or its affiliated entities. > > > CONFIDENTIALITY NOTICE: This e-mail and any files attached may contain > confidential and proprietary information of Alcatel-Lucent and/or its > affiliated entities. Access by the intended recipient only is > authorized. Any liability arising from any party acting, or refraining > from acting, on any information contained in this e-mail is hereby > excluded. If you are not the intended recipient, please notify the > sender immediately, destroy the original transmission and its > attachments and do not disclose the contents to any other person, use it > for any purpose, or store or copy the information in any medium. > Copyright in this e-mail and any attachments belongs to Alcatel-Lucent > and/or its affiliated entities.
-- Laurent Rustuel, Alten contractor for Genesys, an Alcatel-Lucent Company ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2746878

