com.fasterxml.jackson.databind.JsonMappingException

问题描述:在对订单进行上传的时候,其实就是一个excel文件,发现controller对业务层代码调用老是出问题,排查原因时发现原来时被同事的AOP给拦截了,用JackSon对流进行打印导致的异常。

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Failed to load class ‘sun.nio.ch.FileChannelImpl$Access4JacksonSerializer0370ba83‘: com.fasterxml.jackson.module.afterburner.ser.BeanPropertyAccessor (through reference chain: java.io.FileInputStream["channel"])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:291)
at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1124)
at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1146)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1263)
at com.fasterxml.jackson.databind.SerializerProvider.findPrimaryPropertySerializer(SerializerProvider.java:653)
at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddPrimarySerializer(PropertySerializerMap.java:64)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.java:874)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:682)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:690)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:155)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3681)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3057)
at com.wormpex.common.json.JsonMapper.writeValueAsString(JsonMapper.java:1029)
... 24 more
Caused by: java.lang.IllegalArgumentException: Failed to load class ‘sun.nio.ch.FileChannelImpl$Access4JacksonSerializer0370ba83‘: com.fasterxml.jackson.module.afterburner.ser.BeanPropertyAccessor
at com.fasterxml.jackson.module.afterburner.util.MyClassLoader.loadAndResolve(MyClassLoader.java:100)
at com.fasterxml.jackson.module.afterburner.ser.PropertyAccessorCollector.generateAccessorClass(PropertyAccessorCollector.java:171)
at com.fasterxml.jackson.module.afterburner.ser.PropertyAccessorCollector.findAccessor(PropertyAccessorCollector.java:97)
at com.fasterxml.jackson.module.afterburner.ser.SerializerModifier.changeProperties(SerializerModifier.java:63)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.java:412)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.java:282)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:234)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:168)
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1308)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1258)
... 34 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.module.afterburner.ser.BeanPropertyAccessor
at java.lang.ClassLoader.findClass(ClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at com.fasterxml.jackson.module.afterburner.util.MyClassLoader.loadAndResolve(MyClassLoader.java:94)
... 43 more

解决方法:

这段诡异的异常信息浪费了我一下午的时间,还是跟踪调用栈靠谱,以下是跟踪栈发现的信息:

[org.springframework.aop.interceptor.ExposeInvocationInterceptor.ADVISOR, InstantiationModelAwarePointcutAdvisor: expression [execution(* com..xxx.xxx.xxx.xxx.biz..impl.*.*(..))]; advice method

时间: 2024-11-05 22:38:49

com.fasterxml.jackson.databind.JsonMappingException的相关文章

【jackson 异常】com.fasterxml.jackson.databind.JsonMappingException异常处理

项目中,父层是Gene.java[基因实体]  子层是Corlib.java[文集库实体],一种基因对用多个文集库文章 但是在查询文集库这个实体的时候报错:[com.fasterxml.jackson.databind.JsonMappingException] 1 com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassis

400 bad Request: JackSon将json串转成List<Object>,异常com.fasterxml.jackson.databind.JsonMappingException

最近遇到的400, 以前总以为 400 就是参数不匹配造成的,直到今天遇到这个问题 控制台报错如下:  com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.infs.xyc.vo.......... 原因是: 封装参数的类中,重写了带参数的构造方法,却忘记生成默认的构造方法了 !!!

meta对象写入json错误:com.cutt.zhiyue.android.api.io.exception.JsonFormaterException: com.fasterxml.jackson.databind.JsonMappingException

首先说明出现的原因:json这个东西不够智能,在解析javabean对象中的getter和setter方法时,会把两个方法命名十分相近的方法当成一个.从而形成异常. 解决办法:重新命名方法名. 同时需要注意:json在写入某一个meta对象时,会将其所关联的meta对象统统捋一遍(不一定是重置,可能仅仅是遍历一下). 这是我们的json写入异常: com.cutt.zhiyue.android.api.io.exception.JsonFormaterException: com.fasterx

SpringBoot JPA懒加载异常 - com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy

问题与分析 某日忽然发现在用postman测试数据时报错如下: com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy [com.cbxsoftware.cbx.attachment.entity.RefAttachment#c109ec36e60c4a89a10eabc72416d984] - no Session (through reference chain: com.cbxsoftw

Spark和Kafka在IDEA整合运行时提示''com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.9.1''

使用kafka和sparkstreaming整合时,IDEA运行程序报错"com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.9.1",初步看是版本不兼容,但是版本后面确认没有问题,参考博文,修改了依赖包的依赖顺序就解决了问题. 依赖包顺序 修改了依赖包顺序,前三个如图所示的顺序是ok的. ①spark安装包中的jar包 ②kafka安装包中的jar包 ③sparkst

com.fasterxml.jackson.databind.ObjectMapper操作对象和集合的一些相互转换用法

概述 JacksonTest AccountBean Birthday 概述 原文链接:http://blog.csdn.net/u011506468/article/details/47342667 最近用到了ObjectMapper,做了些实验.主要有以下一些转换方式: JavaBean(Entity/Model)转换成JSON 将Map集合转换成Json字符串 将List集合转换成json 将json字符串转换成JavaBean对象 将json字符串转换成List集合 将json字符串转换

at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields异常

at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:666) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:156) at com.fasterxml.jackson.databind.ser.impl.IndexedListSe

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ExceptionId"

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "ExceptionId" (class com.tongyan.ems.model.request.SynchronizedBean), not marked as ignorable (2 known properties: "cityIds", "exceptionId"]

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "FileSize"

请求阿里云的OSS接口图片信息,返回json格式的数据,通过ObjectMapper将json转为Image对象时候报错转换失败 将json转对象的代码: String jsonStr = "{\n" + " \"FileSize\": {\"value\": \"25929\"},\n" + " \"Format\": {\"value\": \"