Open
Description
Restlet 2.3.12 with org.restlet.ext.jackson
I've got this method on a Resource
that is used to dispatch some calls internally via RIAP:
protected Response dispatch(Method method, String url, Map body) {
Request req = new Request(method, "riap://component" + url);
JacksonRepresentation<Map> rep = new JacksonRepresentation<>(body);
rep.setMediaType(MediaType.APPLICATION_JSON);
rep.setCharacterSet(CharacterSet.UTF_8);
req.setEntity(rep);
Response res = getContext().getClientDispatcher().handle(req);
getResponse().setStatus(res.getStatus());
return res;
}
where args are Method.PUT
, "/tasks/59706be"
, and a simple Map such as:
{ "id":"59706be0162c3fed9911315f",
"name":"Task ONE d",
"modifiedTimestamp":"2018-01-23T15:28:18.773Z"
}
Since moving to Jackson instead of the default json.org it throws this exception:
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:508) ~[classes/:?]
when trying to invoke through reflection the target resource method annotated with @Put
java.lang.reflect.Method.invoke(Object, Object...)
specifically in that method the line 498:
return ma.invoke(obj, args);
where obj
is the target resource and args
is an array whose only member is the map above.
If I use JsonRepresentation
again instead of JacksonRepresentation
works fine as before.