Spring MVC + JSON = 406 Not Acceptable

I'm trying to generate a simple JSON response working. Right now I get 406 Not Acceptable error. Tomcat says "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers." even though my Accept headers are


In tomcat/lib I have all Tomcat jars, Spring jars and jackson-all-1.9.0.jar. I'm using Spring 3.2.2 with Tomcat 7.

I'm aware that this issue has been discussed many times, but none of solutions is working for me.


<web-app id="WebApp_ID" version="2.4" 

  <display-name>Spring Web MVC Application</display-name>





<beans xmlns="http://www.springframework.org/schema/beans"

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        <property name="prefix">
        <property name="suffix">
 <context:component-scan base-package="com.smiechmateusz.controller" />
 <context:annotation-config />

    <mvc:annotation-driven />



package com.smiechmateusz.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.smiechmateusz.dao.Foo;

public class HelloWorldController extends AbstractController{

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
        HttpServletResponse response) throws Exception {

        ModelAndView model = new ModelAndView("HelloWorldPage");
        return model;

    @RequestMapping(value="foobar.htm", method = RequestMethod.GET)
    public @ResponseBody Foo getShopInJSON() {
        Foo f = new Foo();
        return f;


package com.smiechmateusz.dao;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

public class Foo implements Serializable
    private int x, y;
    String description;
    int id;

    @Column(name = "x")
    public int getX() {
        return x;
    public void setX(int x) {
        this.x = x;
    @Column(name = "y")
    public int getY() {
        return y;
    public void setY(int y) {
        this.y = y;
    @Column(name = "description")
    public String getDescription() {
        return description;
    public void setDescription(String description) {
        this.description = description;

    @Id @GeneratedValue
    @Column(name = "id")
    public int getId() {
        return id;
    public void setId(int id) {
        this.id = id;

I've already tried adding

<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <ref bean="jsonConverter"/>

to my dispatcher-servlet.xml or changing jakcson-all to jackson-asl and jackson-core-asl but output was the same.



That should be the problem. JSON is served as application/json. If you set the Accept header accordingly, you should get the proper response. (There are browser plugins that let you set headers, I like "Poster" for Firefox best)

If you're using Maven and the latest Jackson code then you can remove all the Jackson-specific configuration from your spring configuration XML files (you'll still need an annotation-driven tag <mvc:annotation-driven/>) and simply add some Jackson dependencies to your pom.xml file. See below for an example of the dependencies. This worked for me and I'm using:

  • Apache Maven 3.0.4 (r1232337; 2012-01-17 01:44:56-0700)
  • org.springframework version 3.1.2.RELEASE
  • spring-security version 3.1.0.RELEASE.


Need Your Help

Using multiple or only one eventlisteners in actionscript 3

actionscript-3 flash class events actionscript

Sorry for the lame question but I don't know how to search for it. So if I have two events from the same class like:

Open File dialogue for Windows 8 Apps

c# visual-studio-2012 windows-8.1

I am making an App in which user is required to choose video from Computer; I want to implement this using OpenFileDiaglogue box as we do for C# Windows Apps which is not available for windows 8 ap...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.