Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

com.alibaba.fastjson.JSONException: Failed resolution of: Ljavax/xml/bind/annotation/XmlAccessorType; #2105

Closed
zwonb opened this issue Oct 26, 2018 · 15 comments
Assignees
Milestone

Comments

@zwonb
Copy link

zwonb commented Oct 26, 2018

解析数据异常
com.alibaba.fastjson.JSONException: Failed resolution of: Ljavax/xml/bind/annotation/XmlAccessorType;

@zwonb
Copy link
Author

zwonb commented Oct 26, 2018

使用1.2.51

@wenshao
Copy link
Member

wenshao commented Nov 1, 2018

能提供更详细的错误堆栈么?

@zwonb
Copy link
Author

zwonb commented Nov 3, 2018

@wenshao
image

@wenshao wenshao added this to the 1.2.53 milestone Nov 18, 2018
@zqr95518
Copy link

zqr95518 commented Nov 27, 2018

一样的问题 1.2.52

2018-11-27 14:13:33.711 13410-13410/com.les.tdcode E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.les.tdcode, PID: 13410
    java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/bind/annotation/XmlAccessorType;
        at com.alibaba.fastjson.util.JavaBeanInfo.build(JavaBeanInfo.java:811)
        at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.<init>(JavaBeanDeserializer.java:48)
        at com.alibaba.fastjson.parser.ParserConfig.createJavaBeanDeserializer(ParserConfig.java:772)
        at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:621)
        at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:393)
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1210)
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:826)
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:1028)
        at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:1281)
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1218)
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:826)
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:785)
        at com.alibaba.fastjson.JSONObject.getObject(JSONObject.java:143)
        at com.les.tdcode.activity.construct.ConstructViewActivity$2.onResponse(ConstructViewActivity.java:69)
        at com.les.tdcode.activity.construct.ConstructViewActivity$2.onResponse(ConstructViewActivity.java:66)
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
        at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
        at android.os.Handler.handleCallback(Handler.java:808)
        at android.os.Handler.dispatchMessage(Handler.java:101)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.bind.annotation.XmlAccessorType" on path: DexPathList[[zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/base.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_resources_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.alibaba.fastjson.util.JavaBeanInfo.build(JavaBeanInfo.java:811) 
        at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.<init>(JavaBeanDeserializer.java:48) 
        at com.alibaba.fastjson.parser.ParserConfig.createJavaBeanDeserializer(ParserConfig.java:772) 
        at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:621) 
        at com.alibaba.fastjson.parser.ParserConfig.getDeserializer(ParserConfig.java:393) 
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1210) 
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:826) 
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:1028) 
        at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:1281) 
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1218) 
        at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:826) 
        at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:785) 
        at com.alibaba.fastjson.JSONObject.getObject(JSONObject.java:143) 
        at com.les.tdcode.activity.construct.ConstructViewActivity$2.onResponse(ConstructViewActivity.java:69) 
        at com.les.tdcode.activity.construct.ConstructViewActivity$2.onResponse(ConstructViewActivity.java:66) 
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67) 
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30) 
        at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99) 
        at android.os.Handler.handleCallback(Handler.java:808) 
        at android.os.Handler.dispatchMessage(Handler.java:101) 
        at android.os.Looper.loop(Looper.java:166) 
        at android.app.ActivityThread.main(ActivityThread.java:7523) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 
    	Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.les.tdcode-K6iObTGlXQ92slJjRNpVlw==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:353)
        at dalvik.system.DexFile.<init>(DexFile.java:100)
2018-11-27 14:13:33.713 13410-13410/com.les.tdcode E/AndroidRuntime:     at dalvik.system.DexFile.<init>(DexFile.java:74)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:75)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:38)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:719)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:752)
        at android.app.LoadedApk.getResources(LoadedApk.java:1005)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2489)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6491)
        at android.app.ActivityThread.-wrap2(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        		... 5 more

@zqr95518
Copy link

@zwonb 暂时把版本回退到1.2.47就没有问题

@zwonb
Copy link
Author

zwonb commented Nov 27, 2018

@zqr95518 我用1.2.49的也没问题。。。到时候不想用这个库了 项目已经用kotlin重构完成,有时间换成moshi

@zwonb
Copy link
Author

zwonb commented Nov 27, 2018

@zqr95518 你试试1.2.53看看行不行,我没去试过

@liyzay
Copy link

liyzay commented Nov 28, 2018

@zwonb @zqr95518
我也在Android上遇到了这个问题,我大致复现了一下步骤。由于项目中使用了RxJava2,而RxJava2不允许传null对象,所以自定义了一个“EmptyObject”来使用,在解析成“EmptyObject”的过程中会出错,必定重现,大致跟了一下代码,确定了出错的原因:
1

2

在JavaBeanInfo的L810会对空对象做判断,而XmlAccessorType在Android上是不存在的,故此报错。

解决方案:替换成最新的”1.1.70.android‘即可。

@wenshao wenshao modified the milestones: 1.2.54, 1.2.55 Nov 29, 2018
@dwing4g
Copy link

dwing4g commented Dec 4, 2018

@wenshao
现在 OpenJDK 11.0.1 也没有 XmlAccessorType 了, 这个貌似是JavaEE的部分,现在已经被JDK11移除了.
我试了 fastjson 1.2.54 仍然依赖这个.

@wenshao wenshao modified the milestones: 1.2.55, 1.2.56 Jan 20, 2019
@wenshao
Copy link
Member

wenshao commented Jan 26, 2019

android版本为啥不用1.1.70.android?

@wenshao wenshao modified the milestones: 1.2.56, 1.2.57 Jan 26, 2019
@WhatAKitty
Copy link

@wenshao https://gunnarmorling.github.io/jdk-api-diff/jdk10-jdk11-api-diff.html
XmlAccessorType 已被移除,希望能尽快修复,目前只能回退到低版本使用。

@wenshao
Copy link
Member

wenshao commented Apr 11, 2019

1.2.56已经修复了,你试试1.2.56

@wenshao wenshao self-assigned this Apr 11, 2019
@dwing4g
Copy link

dwing4g commented Apr 11, 2019

1.2.56已经修复了,你试试1.2.56

1.2.56 是1月27日发布的, 是不是要等下个1.2.57版本?

@wenshao
Copy link
Member

wenshao commented Apr 11, 2019

https://github.com/alibaba/fastjson/releases/tag/1.2.57
问题已修复,请用新版本

@wenshao wenshao closed this as completed Apr 11, 2019
@FightingForDevelop
Copy link

-keep public class javax.**
添加这个混淆

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants