java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException 异常解决方案

问题:

在SpringMVC中使用Jackson实现json输出时配置如下:

	<!-- 输出对象转JSON支持   -->
 	<bean id="stringConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/plain;charset=UTF-8</value>
            </list>
        </property>
    </bean>  

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

    <bean
        class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <list>
                <ref bean="stringConverter"/>
                <ref bean="jsonConverter" />
            </list>
        </property>
    </bean>  

Maven 坐标情况如下:

<dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-servlet_2.5_spec</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.2.10.RELEASE</version>
    </dependency>
    <dependency>
	<groupId>com.fasterxml.jackson.jaxrs</groupId>
	<artifactId>jackson-jaxrs-xml-provider</artifactId>
	<version>2.4.1</version>
    </dependency>

出现异常如下:

严重: Servlet /pcrm threw load() exception
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
	at java.lang.Class.getDeclaredConstructors(Class.java:1901)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:231)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1003)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:976)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:602)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1279)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1192)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)

一开始以为没有导入Jackson的Jar包,但排查后发现Maven坐标有了,Jar包也导入项目了,但还是一直错。于是我在导入的Jackson包中查找 org.codehaus.jackson.JsonProcessingException类,发现导入的Jackson包中,并不是org.codehaus的Jackson包,而是com.fasterxml的Jackson包。所以确定是Maven坐标导错了。

解决方案:

  <dependency>
		<groupId>com.fasterxml.jackson.jaxrs</groupId>
		<artifactId>jackson-jaxrs-xml-provider</artifactId>
		<version>2.4.1</version>
	</dependency>

改成

    <dependency>
           <groupId>org.codehaus.jackson</groupId>
           <artifactId>jackson-mapper-asl</artifactId>
           <version>1.9.4</version>
     </dependency>
				
时间: 2024-10-16 13:03:38

java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException 异常解决方案的相关文章

hadoop出现ava.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/map/JsonMappingException at org.apache.hadoop.mapreduce.Job$1.run(Job.java:563) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.

java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException

1.错误描述 严重: Servlet /huxs threw load() exception java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.

java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition的解决方案

今天在GitHub上面看到一个有意思的项目,下载下来,使用tomcat部署失败,出现异常,网上说JDK版本太高,改低,还是失败. 由于本人有个习惯,更喜欢把项目直接放入tomcat webapps 里面直接部署,通过console观察部署状态.当时这么做,项目照常能走. 玩了一下项目之后,需要使用IDE 走DeBug看看流程,更改JDK,JRE版本之后,还是出现了这样的异常 五月 12, 2017 7:08:10 下午 org.apache.catalina.core.AprLifecycleL

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLstener解决方案

错误原因: 我是因为在写web服务测试时,在lib下面创建了spring和cxf文件夹,相应的jar包在这两个对应文件夹下 解决方法: 删除spring和cxf文件夹,把所有有关的jar包放在lib文件夹下即可.如果删除不了就关掉工具找到项目路径处去手动删除. 网上其它解决方案:http://www.educity.cn/wenda/456617.html 第一 可能是web.xml配置spring监听器 错误 第二 就是你碰到的少了spring 包 第三 把其他无关项目都关闭 tomcat下也

java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException 报错

在测试testSave方法是报错 具体报错如下: 1 java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException 2 3 at java.lang.Class.getDeclaredMethods0(Native Method) 4 at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) 5 at java.lang.Cla

maven web启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

问题描述 SEVERE: Error configuring application listener of class org.springframework.web.util.Log4jConfigListener java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener 解决方案同 maven项目Tomcat controller 404

【异常】Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException

Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationException at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(U

Jenkins的slave异常:Exception in thread &quot;main&quot; java.lang.ClassNotFoundException: hudson.remoting.Launcher

当任务分配到slave上执行时,报如下错误: Parsing POMs Established TCP socket on 38257 maven33-agent.jar already up to date maven33-interceptor.jar already up to date maven3-interceptor-commons.jar already up to date [b012ef95d917292e062fe3d70c7a9b01] $ java -cp /var/l

java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException

我从0手动搭建框架,启动tomcat,遇到这个错:java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException 解决方法:pom.xml中添加如下,就好了 <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId>