jyriand jyriand - 1 month ago 17
JSON Question

Spring MVC and JSON, Jackson class not found exception

I cant get Spring's JSON support working. In my spring-servlet.xml file i have included following lines:

<mvc:annotation-driven/>
<context:component-scan base-package="my.packagename.here" />
<context:annotation-config />

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

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


I have also downloaded jackson libraries and added them to my eclipse project and also to WEB-INF/lib folder. When sending request to controller with jQuery getJSON method i get following errors:

javax.servlet.ServletException: Servlet.init() for servlet dispatcher threw exception
java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonProcessingException
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException


What do you think is the problem. I'm guessing it has something to do with my
spring-servlet.xml
file. I can paste entire error log, if you need.

Answer

JsonProcessingException is part of the jackson-core-asl-x.x.x.jar. Make sure that it's part of your classpath.