Clicky

Spring, Java - @ResponseBody(JSON) request returning Internal Server Error 500

September 8, 2015

Problem:

Requests to return an JSON object returns Internal Server Error 500

Solution:

Controller:

@RequestMapping(method = RequestMethod.GET, value = "/get")
public @ResponseBody Question getQuestionsAjax() {
  (...)
  returnĀ (...);
}

mvc-dispatcher-servlet.java:

mvc:annotation-driven/

<bean id="jacksonMessageConverter” class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter”/>

Pom.xml

<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.9.0</version> </dependency>

<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-asl</artifactId> <version>1.9.0</version> </dependency>

@RequestMapping(method = RequestMethod.GET, value = "/get")  
  public @ResponseBody Question getQuestionsAjax() {  
    (...)  
  return (...);  
 }