I have a rest enabled web service exposed which returns RETURN_OBJ.
However, RETURN_OBJ in itself contains several complex objects like list of objects from other class, maps, etc.
In such a case, will annotating the participating classes with @XmlRootElement and annotating web service with @Produces("application/json") enough?
Because just doing it is not working and I am getting no message body writer found for class error.
What is the reason, cause and solution for this error?
You need to use a libary with json annotations instead of xml annotations. ex: jackson (http://jackson.codehaus.org/). You can try to use a xml writer to write json.
When the classes are annotated with the json annotations, json will be returned.