I'm trying to develop an application where I would like to use org.springframework.http.converter.json.MappingJac ksonHttpMessageConverter class to convert javabeans to json.

The case is I'd like use declarative options in app-servet-xml.

When I start the server I get following exception:

PHP Code:
javax.servlet.ServletExceptionServlet.init() for servlet objectverse threw exception
    org
.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    
com.springsource.server.web.tomcat.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:37)
    
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
    
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    
java.lang.Thread.run(Thread.java:619)

root cause

org
.springframework.beans.factory.BeanCreationExceptionError creating bean with name 'jsonHttpMessageConverter' defined in ServletContext resource [/WEB-INF/objectverse-servlet.xml]: Instantiation of bean failednested exception is org.springframework.beans.BeanInstantiationExceptionCould not instantiate bean class [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter]: Constructor threw exceptionnested exception is java.lang.NoClassDefFoundErrororg/codehaus/jackson/map/ObjectMapper
    org
.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
    
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:890)
    
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
    
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
    
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
    
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
    
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
    
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
    
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
    
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
    
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    
javax.servlet.GenericServlet.init(GenericServlet.java:212)
    
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    
com.springsource.server.web.tomcat.ApplicationNameTrackingValve.invoke(ApplicationNameTrackingValve.java:37)
    
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
    
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    
java.lang.Thread.run(Thread.java:619
Why?

My app-servlet.xml looks like
PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
        
    <!-- Configures the @Controller programming model -->
    <mvc:annotation-driven />
    
    <!-- enable classpath scanning -->
    <context:component-scan base-package="objectverse.web" />
    
    <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" >
        <property name="supportedMediaTypes" value="application/json" />    
    </bean>  
    
    <!--
    Maps incoming requests to the appropriate controller based on the annotations on
    the controller methods.
    -->
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <util:list id="beanList">  
                <ref bean="jsonHttpMessageConverter" />  
            </util:list> 
        </property>
    </bean>
    
    <!-- configure FreeMarker support -->
    <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/WEB-INF/ftl/" />
    </bean>

    <bean id="viewResolver"    class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="cache" value="true" />
        <property name="suffix" value=".ftl" />
    </bean>
    
</beans>
My pom.xml
PHP Code:
...
    <
dependencies>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.spring-library</artifactId>
            <
type>libd</type>
            <
scope>provided</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>spring-webmvc</artifactId>
            <
scope>provided</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.web</artifactId>
            <
version>${org.springframework-version}</version>
            <
type>pom</type>
            <
scope>compile</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.expression</artifactId>
            <
version>${org.springframework-version}</version>
            <
type>pom</type>
            <
scope>compile</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.freemarker</groupId>
            <
artifactId>com.springsource.freemarker</artifactId>
            <
scope>compile</scope>
        </
dependency>
        <
dependency>
            <
groupId>javax.servlet</groupId>
            <
artifactId>com.springsource.javax.servlet</artifactId>
            <
scope>provided</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.junit</groupId>
            <
artifactId>com.springsource.org.junit</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.test</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.aspects</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.springframework</groupId>
            <
artifactId>org.springframework.instrument</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.apache.commons</groupId>
            <
artifactId>com.springsource.org.apache.commons.dbcp</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>com.h2database</groupId>
            <
artifactId>com.springsource.org.h2</artifactId>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.aspectj</groupId>
            <
artifactId>org.aspectj-library</artifactId>
            <
type>libd</type>
            <
scope>test</scope>
        </
dependency>
        <
dependency>
            <
groupId>org.codehaus.jackson</groupId>
            <
artifactId>jackson-mapper-asl</artifactId>
            <
version>1.6.0</version>
        </
dependency>
        <
dependency>
            <
groupId>org.joda</groupId>
            <
artifactId>com.springsource.org.joda.time</artifactId>
            <
version>1.6.0</version>
        </
dependency>
        <
dependency>
            <
groupId>org.codehaus.jackson</groupId>
            <
artifactId>com.springsource.org.codehaus.jackson</artifactId>
            <
version>1.4.3</version>
        </
dependency>
        <
dependency>
            <
groupId>org.codehaus.jackson</groupId>
            <
artifactId>com.springsource.org.codehaus.jackson.mapper</artifactId>
            <
version>1.4.3</version>
        </
dependency>         
    </
dependencies>
... 
Best regards,
Bojan