openzipkin / zipkin-reporter-java

Shared library for reporting zipkin spans on transports such as http or kafka
Apache License 2.0
126 stars 70 forks source link

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

Closed maheskrishnan closed 11 months ago

maheskrishnan commented 3 years ago

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

jcchavezs commented 3 years ago

Is this an issue in our end @anuraaga?

On Fri, 29 Jan 2021, 16:56 Maheswaran Krishnan, notifications@github.com 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 .

maheskrishnan commented 3 years ago

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.
codefromthecrypt commented 11 months ago

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