I'm trying to send send a generic collection to a resource using this
code(ResourceElement is just an empty interface):
public abstract class BaseSender<T extends ResourceElement> {
protected Collection<T> resourceElements = new ArrayList<T>();
public Collection<Message> send() {
GenericType<Collection<Message>> outputGenericType = new
GenericType<Collection<Message>>() {};
GenericEntity<Collection<T>> genericInput = new
GenericEntity<Collection<T>>(resourceElements) {};
return
serviceResource.type(MediaType.APPLICATION_JSON).post(outputGenericType,
genericInput);
}
}
I have a concrete class (e.g. EmailSender extends BaseSender) for each class
that implements ResourceElement. When running the code I get an exception:
"A message body writer for Java type, class java.util.ArrayList, and MIME
media type, application/json, was not found".
I thought that using GenericEntity will solve this problem but it doesn't
work. Is there any solution for this or do I have to duplicate the sending
code for each ResourceElement type?
--
View this message in context: http://jersey.576304.n2.nabble.com/Sending-generic-collections-with-bounded-types-tp7234178p7234178.html
Sent from the Jersey mailing list archive at Nabble.com.