I'm trying to do Spring MVC REST JSON channel with automatic conversion to JSON using Jackson. Although I'm doing everything as recommended in other StackOverflow questions, I'm getting HttpMediaTypeNotAcceptableException and my beans/lists are not converted to JSON. I'm running the code on Jetty.

So the question is, what I'm missing here? Why the jackson converter is not registered/how can I debug it? I'm running the code via jetty:run. But it should not matter, since Spring is application-server-independent.

1 Answer
1

In your @RequestMapping you have produces = "text/plain", but your request header says Accept application/json, text/javascript. There is no match.

Use either produces="application/json" or don't use produces at all. It's main use case is to provide more than one method for the same URL, each producing output in a different format (JSP, JSON, XML ...).

Yes, yesterday I had procuces application/json but then I was changing it for tests. Today I've applied the solutions from stackoverflow, but I've forgotten to change the produces.
–
Р̀СТȢѸ́ФХѾЦЧШЩЪЫЬѢѤЮѦѪѨѬѠѺѮѰѲѴJun 28 '13 at 9:38