0

When The Program is Ran in the Local PC, it is working fine, but if it is running in the docker throws the following error:

Exception in thread "Thread-16" java.lang.NoClassDefFoundError: org/apache/kafka/common/serialization/Serializer
    at org.eclipse.kura.example.configurable.ConfigurableExample$1.run(ConfigurableExample.java:52)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.common.serialization.Serializer cannot be found by org.eclipse.kura.example.configurable_1.0.0.202201251713
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 2 more

But this is working fine in the LocalMachine. What is the issue ?

4
  • 1
    Looks like missing a kafka dependency. Commented Jan 25, 2022 at 9:43
  • @RealSkeptic, this issue is not seen when running in local machine, how can this be solved ? Commented Jan 25, 2022 at 11:21
  • 1
    You need to explain how you are running code on your "local machine". Obviously Docker isn't using the same Java command you've given to run it locally. Most obvious example would be that your IDE may Austin's include all declared dependencies in the classpath, but building a non fat-jar does not Commented Jan 25, 2022 at 14:08
  • Am facing similar issue. Any resolution that worked? Commented Feb 23, 2023 at 4:31

1 Answer 1

1

This may be debugged in following ways:

  1. Ensure that you have all the required dependencies inside your docker container. You may want to check your docker base image first.
  2. Check if you have set the classpath appropriately to include that jar file (kafka-clients).
  3. Validate your entrypoint/cmd which you use to start the service to check if it has the appropriate classpath.
  4. Check your classloader and see why it is not able to load that class.
  5. If your executable is a fat jar file, check if that jar file contains the kafka-clients library where that class is present.
Sign up to request clarification or add additional context in comments.

1 Comment

Tried All ways as you suggested, this didn't help, the issue still exists. May be there is an issue with the Kafka code written by me, not sure...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.