I have a dynamic web project in Java (deployed on a local application server Tomcat 7) which uses Jersey for creating REST APIs.
I do not use any build automation to
You should tell Jersey to use Gson for JSON handling. You can do this implementing the MessageBodyReader
and MessageBodyWriter
interfaces provided by Jersey.
In this stackoverflow question you can find an example (see the accepted answer).
If you want to add some context to it, take a look at
the JSON section of the Jersey 1.x manual
EDIT :
I may not be understanding your code, but where is the call to Gson in your
UserBeanMessageBodyReader
?
Try chaging the reaedFrom
method with something along the lines of
String result = new BufferedReader(new InputStreamReader(entityStream))
.lines().collect(Collectors.joining("\n"));
Gson gson = new GSon();
User myUser = gson.fromJson(result, User.class);
instead of using JAXBContext
(which afaict understands only XML inputs).