My application uses a REST (JAX-RS Jersey) interface. When I run it in Eclipse, everything' s fine. The domain objects are annotated, I'm not using XML files for the REST mapping.
Now I created a standalone JAR using the maven-assembly-plugin, which packs the application and all dependencies in a single, executable JAR file. This also seems to work.
But when I start the application and request an object from the server, Jersey complains, that it can't find a message body reader:
com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java type, class de.rybu.atuin.core.entity.User, and MIME media type, application/json, was not found
Any ideas why this happens?
EDIT: After I slept a night over it, I noticed that it complains about JSON... but I'm using only XML for serialization. Strange.
I fixed the problem and I guess I know how :-)
My resources were annotated like this:
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path(CONTEXT_ADDRESS)
public class UserResource
{
}
My client used the reverse order:
WebResource wr = ...
User user = wr.accept(MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE).get(new GenericType<User>(){});
I don't know what initially caused the problem but I completely removed JSON-support and now it works. Maybe it would have been sufficient to simply swith the order of JSON and XML in the client but I didn't try that.