I have the following get request to a RESTful web service:
List entries = client.target("http://localhost:8080/MMServer/webresources/shopping/getEntries")
.request(MediaType.APPLICATION_JSON)
.get()
.readEntity(new GenericType>() {});
and the corresponding resource
@GET
@Path("getEntries")
@Produces(MediaType.APPLICATION_JSON)
public List getShoppingBundle() {
List shoppingEntries = new ArrayList<>();
List shoppingList = super.findAll();
ShoppingEntry entry;
for (Shopping s: shoppingList) {
entry = new ShoppingEntry();
entry.setName(s.getIdperson().getFirstname());
entry.setDate(s.getDate());
entry.setAmount(s.getAmount());
entry.setStore(s.getStore());
shoppingEntries.add(entry);
}
return shoppingEntries;
}
The problem: Sometimes the program runs without error and everything is alright. But most of the time i get the following exception:
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/html, type=interface java.util.List, genericType=java.util.List.
which says: "type=text/html" what should be the cause. How can this happen?
My dependencies are:
org.glassfish.jersey.core
jersey-client
2.26
org.glassfish.jersey.inject
jersey-hk2
2.26
org.glassfish.jersey.core
jersey-common
2.26