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);
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
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2746057