zipkin-reporter-java icon indicating copy to clipboard operation
zipkin-reporter-java copied to clipboard

Class loading error: ByteArraySerializer could not be found when using KafkaSender.

Open maheskrishnan opened this issue 3 years ago • 2 comments

I am getting this error when opentelemetry is trying to export traces to Kafka using Kafka sender.

[BatchSpanProcessor_WorkerThread-1] WARN io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker - Exporter threw an Exception org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.ByteArraySerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.ByteArraySerializer could not be found.

i am using -Dotel.exporter.jar=myexporter.jar option to use my own custom exporter . myexporter.java does contains the org.apache.kafka.common.serialization.StringSerializer. but when running th application getting this error

StackOverFlow Question: https://stackoverflow.com/questions/65946487/class-not-found-error-in-open-telemetry-exporter

Any help is highly appreciated. Thanks

maheskrishnan avatar Jan 29 '21 15:01 maheskrishnan

Is this an issue in our end @anuraaga?

On Fri, 29 Jan 2021, 16:56 Maheswaran Krishnan, [email protected] wrote:

[BatchSpanProcessor_WorkerThread-1] WARN io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker - Exporter threw an Exception org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.ByteArraySerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.ByteArraySerializer could not be found.

i am using -Dotel.exporter.jar=myexporter.jar option to use my own custom exporter . myexporter.java does contains the org.apache.kafka.common.serialization.StringSerializer. but when running th application getting this error

StackOverFlow Question: https://stackoverflow.com/questions/65946487/class-not-found-error-in-open-telemetry-exporter

Any help is highly appreciated. Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/zipkin-reporter-java/issues/199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYAWJFCIRNFYCG6ZD4YDS4LLCBANCNFSM4WZCQA4A .

jcchavezs avatar Jan 30 '21 18:01 jcchavezs

Additional context

this is the command line I am using to start my server

java -javaagent:/path/to/opentelemetry-javaagent-all.jar \
      -Dotel.exporter.jar=/path/to/mykafka-exporter-1.0-jar-with-dependencies.jar \
      -Dotel.exporter.zipkin.service.name=sre-client-service-demo       \
      -Dotel.exporter.zipkin.kafka.bootstrap.servers=localhost:9092     \
      -Dotel.exporter.zipkin.kafka.topic=myapp-sre                   \
       -jar ./.out/libs/server.jar server config.yml
  1. this otel.exporter.jar=/path/to/mykafka-exporter-1.0-jar-with-dependencies.jar DOES contain the org.apache.kafka.common.serialization.ByteArraySerializer
  2. the agent boot loader DOES not have org.apache.kafka.common.serialization.ByteArraySerializer
  3. here is the code from Kafka which tries to dynamically loads ByteArraySerializer class using (Thread.currentThread().getContextClassLoader())
    public static ClassLoader getContextOrKafkaClassLoader() {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if (cl == null)
            return getKafkaClassLoader();
        else
            return cl;
    }

  1. Thread.currentThread().getContextClassLoader() is Bootstrap agent class loader which does not have ByteArraySerializer.
  2. if I change the line "ClassLoader cl = Thread.currentThread().getContextClassLoader();" to "ClassLoader cl = null" it works but Thread.currentThread().getContextClassLoader(); not supposed (in my opinion) to have bootstrap class loader it seems.

maheskrishnan avatar Jan 30 '21 22:01 maheskrishnan

this is not the opentelemetry project, so if this is still an issue, raise it there. this project does not do any classloader related configuration

codefromthecrypt avatar Dec 11 '23 01:12 codefromthecrypt