fastjson net.sf.json.JSONException: Object is null 仍然存在

2ledvvac  于 2021-11-27  发布在  Java
关注(0)|答案(1)|浏览(423)

1.业务代码情况:
1)引用了fastjson1.2.41,json-lib-2.4
2)调用 JSON.toJSONString(Object obj)报错;
3)Object类型为 ResponseInfo<net.sf.json.JSONObject>
4)错误偶现,目前还没发现规律。用报错数据构造 ResponseInfo对象,没走到JavaBeanSerializer.write,writer为ASMSerializer_开头,不会报错。

2.调用栈如下
com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.41, class com.xx.json.ResponseInfo, write javaBean error, fastjson version 1.2.41, class net.sf.json.JSONNull, fieldName : cyyNum
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:432) ~[fastjson-1.2.41.jar:?]

at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:113) ~[fastjson-1.2.41.jar:?]

at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:278) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:669) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:611) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:576) ~[fastjson-1.2.41.jar:?]
at com.xxx.beanToString(xx.java:45) #业务代码 JSON.toJSONString(Object obj)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71) [log4j-web-2.3.jar:2.3]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.35]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.35]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.35]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.35]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) [catalina.jar:8.0.35]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) [tomcat-coyote.jar:8.0.35]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) [tomcat-coyote.jar:8.0.35]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_80]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.35]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_80]
Caused by: com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.41, class net.sf.json.JSONNull, fieldName : voucherNum
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:432) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:113) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:270) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:44) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.writeValue(FieldSerializer.java:284) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:378) ~[fastjson-1.2.41.jar:?]
... 68 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_80]
at com.alibaba.fastjson.util.FieldInfo.get(FieldInfo.java:484) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.getPropertyValueDirect(FieldSerializer.java:135) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:234) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:113) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:270) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:44) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.writeValue(FieldSerializer.java:284) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:378) ~[fastjson-1.2.41.jar:?]
... 68 more
Caused by: net.sf.json.JSONException: Object is null
at net.sf.json.JSONNull.isEmpty(JSONNull.java:69) ~[json-lib-2.4.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_80]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_80]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_80]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_80]
at com.alibaba.fastjson.util.FieldInfo.get(FieldInfo.java:484) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.getPropertyValueDirect(FieldSerializer.java:135) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:234) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:113) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:270) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:44) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.FieldSerializer.writeValue(FieldSerializer.java:284) ~[fastjson-1.2.41.jar:?]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:378) ~[fastjson-1.2.41.jar:?]
... 68 more

0ejtzxu1

0ejtzxu11#

我把json-lib全部转成fastjson接口了,废了json-lib

相关问题