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>
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException 异常解决方案的更多相关文章
- 报错:java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException
报错背景: 执行hdfs-mysql的job任务的时候报错. 报错现象: Exception has occurred during processing command Exception: org ...
- java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcess******
http://blog.csdn.net/jrainbow/article/details/38764039
- Hive报错之java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonFactory
一.问题: 在使用Hive0.11进行select查询的时候报: hive,),site from zhifu; Total MapReduce jobs Launching Job out In o ...
- hadoop出现ava.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/jackson/map/JsonMa ...
- maven项目运行tomcat7-maven-plugin:run时出现Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.util.Scanner(xjl456852原创)
使用tomcat7-maven-plugin插件运行web项目时, 出现下面错误: [WARNING] Error injecting: org.sonatype.plexus.build.incre ...
- java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
RabbitMq配置时常见错误 java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper <de ...
- java.lang.ClassNotFoundException: org.I0Itec.zkclient.IZkStateListener异常解决
在启动Dubbo项目时,出现该异常 java.lang.ClassNotFoundException: org.I0Itec.zkclient.IZkStateListener 解决,引入 <d ...
- java.lang.ClassNotFoundException: org.apache.log4j.Logger 异常
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'd ...
- java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition的解决方案
今天在GitHub上面看到一个有意思的项目,下载下来,使用tomcat部署失败,出现异常,网上说JDK版本太高,改低,还是失败. 由于本人有个习惯,更喜欢把项目直接放入tomcat webapps 里 ...
随机推荐
- jquery 图片懒加载
jquery 图片懒加载 CreationTime--2018年7月1日14点45分 Author:Marydon 1.源码展示 (function(a){a.fn.lazyload=functi ...
- 用记事本编写一个Servlet项目
第一步:建立目录 新建一个文件夹FirstServlet,然后在FirstServlet目录下面再建两个文件夹,分别为:WEB-INF和src.最后在WEB-INF下面建一个classes文件夹 第二 ...
- JDBC 关于大文本数据
大文本数据Clob,在不同的数据库中类型名不一致,有的是text格式,有的是clob,还有其他一些格式 package test; import java.io.BufferedReader; i ...
- screen 命令使用及示例
screen 是一个非常有用的命令,提供从单个 SSH 会话中使用多个 shell 窗口(会话)的能力.当会话被分离或网络中断时,screen 会话中启动的进程仍将运行,你可以随时重新连接到 scre ...
- mysql拼接字符串和过滤字符的方法
数据 id value 1 aa<p>QL实木颗粒</p> 2 bb<p>QL实木颗粒</p> ...
- C++方式解析时间字符串和计算时间
#include "StdAfx.h"#include "MySetTimeByVT.h" #include <ATLComTime.h>#incl ...
- Python3 isidentifier() 方法
描述 Python3 isidentifier() 方法用于判断字符串是否是有效的 Python 标识符,可用来判断变量名是否合法. 语法 isidentifier() 方法语法: S.isident ...
- mysql group replication 安装&配置详解
一.原起: 之前也有写过mysql-group-replication (mgr) 相关的文章.那时也没有什么特别的动力要写好它.主要是因为在 mysql-5.7.20 之前的版本的mgr都有着各种各 ...
- StrongLoop
http://loopback.io/getting-started/ 使用 StrongLoop 创建 Node.js MySQL 应用程序 StrongLoop 是 IBM 的一家子公司,Stro ...
- Spring注解-@Configuration注解、@Bean注解以及配置自动扫描、bean作用域
1.@Configuration标注在类上,相当于把该类作为spring的xml配置文件中的<beans>,作用为:配置spring容器(应用上下文) package com.test.s ...