Weblogic 12.2.1.3上的com.fasterxml.jackson.databind.JsonMappingException

时间:2018-08-13 08:47:52

标签: java serialization jackson weblogic jackson-databind

序列化过程中发生错误。

我尝试更新jackson lib(2.4-> 2.7),将com.fasterxml。*添加到weblogic-application.xml中的preferred-application-packages中,为objectMapper调用setSerializationInclusion(Include.NON_NULL)。

但是错误没有解决。

stacktrace中的对象com.packagename.SavedAction不为null,并且字段也不为空。

Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.packagename.SavedAction[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:391)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:363)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:338)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeTypedContents(ObjectArraySerializer.java:304)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeContents(ObjectArraySerializer.java:226)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:210)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serialize(ObjectArraySerializer.java:22)
at com.mypackaggename.core.json.SaveJsonSerializer.serialize(SaveJsonSerializerSerializer.java:65)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1396)
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1120)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:993)
at com.mypackagename.core.json.ConfiguratedPacker.pack(ConfiguratedPacker.java:63)
at com.mypackagename.core.json.JPHandler.pack(JPHandler.java:86)
... 69 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.fasterxml.jackson.databind.jsontype.TypeSerializer.typeId(TypeSerializer.java:79)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase._typeIdDef(BeanSerializerBase.java:679)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeWithType(BeanSerializerBase.java:599)
at com.mypackaggename.core.json.SaveJsonSerializer.serializeWithType(SaveJsonSerializer.java:110)
at com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer.serializeTypedContents(ObjectArraySerializer.java:301)
... 80 common frames omitted

1 个答案:

答案 0 :(得分:0)

问题是WLS忽略了preferred-application-packages选项,并具有自己的jackson lib版本。 到xmlns规范的链接已更改。

之前:

xmlns =“ http://www.bea.com/ns/weblogic/90” xsi:schemaLocation =“ http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-application.xsd

之后:

xmlns =“ http://xmlns.oracle.com/weblogic/weblogic-application” xsi:schemaLocation =“ http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.3/weblogic-application.xsd

之后,错误已解决。