Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 566
jyriand Avatar asked Feb 07 '12 00:02

jyriand


1 Answers

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

like image 59
gouki Avatar answered Oct 26 '22 09:10

gouki