Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: io/opentracing/util/GlobalTracer in v.1.2.0 #1

Open
orinciog opened this issue Jul 8, 2021 · 3 comments

Comments

@orinciog
Copy link

orinciog commented Jul 8, 2021

Hi!

I'm using your sink, v1.2.0 in a custom Kafka Connect Docker Image, but when I try to start a connector, I receive the following message:

[2021-07-08 15:32:28,797] ERROR WorkerSinkTask{id=EchoSinkConnector-0} Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask:184)
java.lang.NoClassDefFoundError: io/opentracing/util/GlobalTracer
	at cz.scholz.kafka.connect.echosink.EchoSinkTask.start(EchoSinkTask.java:44)
	at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:308)
	at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:196)
	at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:182)
	at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:231)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassNotFoundException: io.opentracing.util.GlobalTracer
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:104)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) 

The dockerfile that I'm using is:

FROM bitnami/kafka:2.8.0
USER root:root

RUN mkdir -p /opt/bitnami/kafka/plugins

RUN wget -q https://github.com/scholzj/echo-sink/releases/download/1.2.0/echo-sink-1.2.0.jar -O /opt/bitnami/kafka/plugins/echo-sink-1.2.0.jar

USER 1001
CMD ["/opt/bitnami/kafka/bin/connect-distributed.sh", "/opt/bitnami/kafka/config/connect-distributed.properties"]

and in connect-distributed.properties I have a line with:
plugin.path=/opt/bitnami/kafka/plugins

The configuration of connector is:

connector.class=cz.scholz.kafka.connect.echosink.EchoSinkConnector
key.converter.schemas.enable=false
topics=topic-test
tasks.max=2
value.converter.schemas.enable=false
value.converter=org.apache.kafka.connect.storage.StringConverter
key.converter=org.apache.kafka.connect.storage.StringConverter

Other connectors (i.e FileStreamSinkConnector) are working fine.

The error is correct, in echo-sink 1.2.0 jar there is no opentracing jar. Actually there are no extra jars inside provided jar.

How can I skip this error?

Thank you

@scholzj
Copy link
Owner

scholzj commented Jul 8, 2021

It looks like you are missing the tracing libraries. You will need to add the Jaeger Client and OpenTracing dependencies: https://github.com/scholzj/echo-sink/blob/main/pom.xml#L31-L40

I can try to have a look later if I can produce some fat-jar as an alternative. But adding these dependencies (and their dependencies) manually should get you started.

@orinciog
Copy link
Author

orinciog commented Jul 9, 2021

Hi,

Thank you for your advice.

It worked by adding the following jars to /opt/bitnami/kafka/libs.

jaeger-tracerresolver-1.0.0.jar                           okhttp-3.9.0.jar                      opentracing-util-0.33.0.jar
gson-2.8.2.jar                                            okio-1.13.0.jar                       libthrift-0.12.0.jar   
jaeger-client-1.0.0.jar                                   opentracing-api-0.33.0.jar            
jaeger-core-1.0.0.jar                                     opentracing-noop-0.33.0.jar           
jaeger-thrift-1.0.0.jar                                   opentracing-tracerresolver-0.1.8.jar

For those who are interested, I downloaded required jars with:
echo-sink-1.2.0/META-INF/maven/cz.scholz.kafka.connect/echo-sink$ mvn dependency:resolve

and after I put in libs folder only those libs which were not present.

I think you should provide a single uber jar with all required jars in it. Actually, this is the way that confluent recommends to ship a connector

A Kafka Connect plugin can be:

a directory on the file system that contains all required JAR files and third-party dependencies for the plugin. This is most common and is preferred.
a single uber JAR containing all of the class files for the plugin and its third-party dependencies.

Important

A plugin should never contain any libraries provided by the Kafka Connect runtime.

Source: https://docs.confluent.io/home/connect/userguide.html

Thank you.

@scholzj
Copy link
Owner

scholzj commented Jul 9, 2021

Well, it is used mainly with Strimzi, which already packages the dependencies. And it is always better to avoid mixing dependencies since that might cause different versions to conflict etc. I might add fat-jar when I have time for it. But not sure when exactly will i get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants