com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
作者原创,转载请注明转载地址
第一次遇到该异常,在网上搜了很长时间也没找到解决答案,特此记录
1.异常展示:
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: java.io.StringReader@11a92b24; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:2931)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2873)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.allcam.system.utils.JSonUtils.readValue(JSonUtils.java:30)
at com.allcam.system.manager.statistics.impl.UserResourceDayStatisticsServiceImpl.getResourceDayStatistics(UserResourceDayStatisticsServiceImpl.java:45)
at com.allcam.system.manager.statistics.impl.UserResourceDayStatisticsServiceImpl$$FastClassByCGLIB$$6b11b7f.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:710)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:643)
at com.allcam.system.manager.statistics.impl.UserResourceDayStatisticsServiceImpl$$EnhancerByCGLIB$$65dd2f5a.getResourceDayStatistics(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy56.getResourceDayStatistics(Unknown Source)
at com.allcam.system.manager.statistics.controller.UserResourceDayStatisticsController.getUserResourceDayStatistics(UserResourceDayStatisticsController.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)[2017-08-16 17:06:54,911][DEBUG][org.apache.http.impl.conn.Wire.wire(Wire.java:72)][http-nio-8080-exec-3] - << "HTTP/1.1 200 OK[\r][\n]" -
[2017-08-16 17:06:54,912][DEBUG][org.apache.http.impl.conn.Wire.wire(Wire.java:72)][http-nio-8080-exec-3] - << "Server: Apache-Coyote/1.1[\r][\n]" -
2.异常解析,本异常报错的原因为调用webservice服务,从webservice返回的对象没有将其转为json对象,而是直接将对象返回了,所以从webservice返回的时候
就报了此错误,
3.解决方案:将webservice返回的对象转化为json格式,,特此将原代码贴出:
@ResponseBody
@RequestMapping(value="resDayStatistics")
public String getUserResourceDayStatistics(HttpServletRequest request,HttpServletResponse response){
UserResourceDayStatistics dayStatistics2 = new UserResourceDayStatistics();
try
{
UserResourceDayStatistics dayStatistics = new UserResourceDayStatistics();
InputStream inputStream= request.getInputStream();
String reqJson=IOUtils.toString(inputStream,ServiceContants.UTF8_CODE);
if(reqJson != null && reqJson != ""){
//json转成UserResourceDayStatistics对象
dayStatistics=JSonUtils.readValue(reqJson, UserResourceDayStatistics.class);
} dayStatistics2=dayService.getResourceDayStatistics(dayStatistics); }
catch (Exception e)
{
e.printStackTrace();
}
// return "/main/webapp/dayStatistics.jsp";
return JSonUtils.toJSon(dayStatistics2); //返回json格式对象
}
}
由于要返回的是一个json对象,所以在方法头上加一个@ResponseBody注解,该注解的作用是将返回结果的格式写入到返回结果中,否则就会解析为一个页面。。。。。。
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input的更多相关文章
- 【jackson 异常】com.fasterxml.jackson.databind.JsonMappingException异常处理
项目中,父层是Gene.java[基因实体] 子层是Corlib.java[文集库实体],一种基因对用多个文集库文章 但是在查询文集库这个实体的时候报错:[com.fasterxml.jackson ...
- 400 bad Request: JackSon将json串转成List<Object>,异常com.fasterxml.jackson.databind.JsonMappingException
最近遇到的400, 以前总以为 400 就是参数不匹配造成的,直到今天遇到这个问题 控制台报错如下: com.fasterxml.jackson.databind.JsonMappingExcept ...
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of j
异常信息如下: JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token ...
- SpringBoot JPA懒加载异常 - com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy
问题与分析 某日忽然发现在用postman测试数据时报错如下: com.fasterxml.jackson.databind.JsonMappingException: could not initi ...
- HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite
org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite r ...
- com.fasterxml.jackson.databind.JsonMappingException
背景 在搭建SSM整合activiti项目时,在查找activiti定义的流程模板时,前台不能够接受到ProcessDefinition这个对象. 原因 ProcessDefinition是一个接口, ...
- 解决com.fasterxml.jackson.databind.JsonMappingException: No suitable
原因:直接翻译,json格式,不匹配. 这原因坑爹啊,因为json格式不正确算一种原因. 还有一种就是接收的bean没有getter,setter方法. 最坑的一种就是数据无法被反序列化,list,m ...
- 实体类中方法名尽量避免set,get,报错com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException)
自己建了一个实体类 public class MissPoint implements Serializable{ private static final long serialVersionUID ...
- com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field 异常
分享牛原创(尊重原创 转载对的时候第一行请注明,转载出处来自分享牛http://blog.csdn.net/qq_30739519) 1.1.1. 前言 近期在使用ObjectMapper对象将jso ...
随机推荐
- Python自动发邮件-yagmail库
之前写过用标准库使用Python Smtplib和email发送邮件,感觉很繁琐,久了不用之后便忘记了.前几天看知乎哪些Python库让你相见恨晚?,看到了yagmail第三方库,学习过程中遇到一些问 ...
- openssl version 查看openssl 版本出现openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory,怎么办
查看openssl版本, 解决办法: ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln -s /usr/local/li ...
- [LeetCode] 261. Graph Valid Tree _ Medium tag: BFS
Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), w ...
- python基础24 -----python中的各种锁
一.全局解释器锁(GIL) 1.什么是全局解释器锁 在同一个进程中只要有一个线程获取了全局解释器(cpu)的使用权限,那么其他的线程就必须等待该线程的全局解释器(cpu)使 用权消失后才能使用全局解释 ...
- Map<String, String>循环遍历的方法
Map<String, String>循环遍历的方法 Map<String, String>循环遍历的方法 Map<String, String>循环遍历的方法 下 ...
- VUE滚动条插件——vue-happy-scroll
最近自己在自学vue2.0,然后就自己摸索做一个简单的后台管理系统,在做的过程中,总感觉不同浏览器自带的滚动条样式不统一,也很难看,所以就在网上找一些使用vue的滚动条插件.最开始用的是Easy-sc ...
- 转载的 Linux下chkconfig命令详解
Linux下chkconfig命令详解 chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. ...
- Verilog篇(四)时序模型
时序模型:仿真器的时间推进模型,它反映了推进仿真时间和调度事件的方式. 1)门级时序模型:适用于分析所有的连续赋值语句,过程连续赋值语句,门级原语,用户自定义原语. 特点:任意时刻,任意输入变化都将重 ...
- STA分析(五) parastics
互联线的寄生参数 一般一个cell或者block的连接pin就叫做一个net.在物理实现的时候,一条net可能会穿过几层metal,因为每个metal层的电阻,电容值都不一样.所以,在分析 net的寄 ...
- CAReplicatorLayer
CAReplicatorLayer CAReplicatorLayer的目的是为了高效生成许多相似的图层.它会绘制一个或多个图层的子图层,并在每个复制体上应用不同的变换.看上去演示能够更加解释这些,我 ...