Kryo序列化错误

时间:2012-08-14 23:45:45

标签: java serialization kryo

我在学校的日食工作时使用拇指驱动器,并将拇指驱动器带回家。

下次运行程序时突然出现了这个错误:

 Exception in thread "main" java.lang.IllegalArgumentException: Unable to create serializer "com.esotericsoftware.kryo.serializers.FieldSerializer" for class: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
    at com.esotericsoftware.kryo.Kryo.newSerializer(Kryo.java:338)
    at com.esotericsoftware.kryo.Kryo.newDefaultSerializer(Kryo.java:317)
    at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:310)
    at com.esotericsoftware.kryo.Kryo.register(Kryo.java:354)
    at com.esotericsoftware.kryonet.KryoSerialization.<init>(KryoSerialization.java:33)
    at com.esotericsoftware.kryonet.KryoSerialization.<init>(KryoSerialization.java:25)
    at com.esotericsoftware.kryonet.Client.<init>(Client.java:73)
    at com.esotericsoftware.kryonet.Client.<init>(Client.java:55)
    at test.TestClient.<init>(TestClient.java:32)
    at test.TestClient.main(TestClient.java:39)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at com.esotericsoftware.kryo.Kryo.newSerializer(Kryo.java:325)
    ... 9 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
    at com.esotericsoftware.reflectasm.FieldAccess.insertConstructor(FieldAccess.java:144)
    at com.esotericsoftware.reflectasm.FieldAccess.get(FieldAccess.java:109)
    at com.esotericsoftware.kryo.serializers.FieldSerializer.rebuildCachedFields(FieldSerializer.java:104)
    at com.esotericsoftware.kryo.serializers.FieldSerializer.<init>(FieldSerializer.java:50)
    ... 14 more

我从未见过这种错误,我不确定如何修复它。每次我使用kryonet库时都会发生这种情况。有可用的解决方案吗?

2 个答案:

答案 0 :(得分:1)

工作中的合作伙伴有同样的错误。它是由使用旧的“asm”库引起的。当最新的Kryo(撰写本文时为2.18)需要asm 4.x时,他正在使用3.X.更新asm库修复了该问题。

答案 1 :(得分:0)

作为Nushio回答,但似乎你有库冲突,你有多个依赖关系引用不同版本的asm,你需要找出通过执行mvn dependency:tree来引发冲突的女巫。之后,您必须在引用错误的asm版本(&lt; 4.x)的依赖项中进行maven排除。