Kryo (Class cannot be created (missing no-arg constructor))
Kryo can serialize Java classes that do not implement Serializable in various ways, but deserializing certain objects, such as those without a no-argument constructor, can produce this error.
Translated from Chinese with AI · Read the original
Kryo can serialize Java classes that do not implement Serializable in various ways, but deserializing certain objects, such as those without a no-argument constructor, can produce this error:
com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor): org.apache.flink.cep.pattern.Pattern
at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy.newInstantiatorOf(Kryo.java:1228) at com.esotericsoftware.kryo.Kryo.newInstantiator(Kryo.java:1049) at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1058) at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:547) at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:523) at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:657)In this case, you can resolve it by using the org.objenesis.strategy.StdInstantiatorStrategy instantiation strategy in Kryo.