Hi, I have a problem with using a kafka sink with ...
# troubleshooting
a
Hi, I have a problem with using a kafka sink with SpecificRecord POJO. I have found the root cause to be, that the org.apache.avro.specific.SpecificRecord is loaded from two different sources inside the cluster. One is from the shaded jar I've supplied, but the other comes from blobStorage I believe (module says from file///tmp/tm 192.168.208.735855-8b5ab0/blobStorage/job_a4a31671e6c5bbb8b7bfa8912b9f4c75/blob_p-6596e9fe6bec88d37998a1e227f2b478e9cd9239-c094703d743cb21bfa6fdd41cf43b617) Inside the serialization step of the Avro record, there is a check that determines to handle the Avro POJO with a certain strategy:
Copy code
static <T> AvroFactory<T> create(Class<T> type, @Nullable Schema currentSchema, @Nullable Schema previousSchema) {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (SpecificRecord.class.isAssignableFrom(type)) {
        return fromSpecific(type, cl, Optional.ofNullable(previousSchema));
    } else {
        return GenericRecord.class.isAssignableFrom(type) ? fromGeneric(cl, currentSchema) : fromReflective(type, cl, Optional.ofNullable(previousSchema));
    }
}
Because my own POJO implements interface org.apache.avro.specific.SpecificRecord that is loaded from that blobStorage file, and the check SpecificRecord.class.isAssignableFrom(type) has the original SpecificRecord from the supplied job jar, it doesn't know how to treat my avro record as a specific record, instead it tried to reflective get the schema, which goes wrong. Any idea how to resolve this issue?
Found the answer, at least to this problem, by setting the dual loaded classes to taskmanager's property classloader.parent-first-patterns.additional: "org.apache.avro." this problem was solved