Hello,

This is my first time trying kafka in Java. I was following this tutorial:

https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+Producer+Example

for the sample code & maven dependencies. I tweaked the code a little for
my needs and run the code in a Thread-based class with the main class
starting up these kafka class threads.

The thread startup fails with

Exception in thread "Thread-0" java.lang.ClassNotFoundException:
example.producer.SimplePartitioner
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at kafka.utils.Utils$.createObject(Utils.scala:458)
at kafka.producer.Producer.<init>(Producer.scala:60)
at kafka.javaapi.producer.Producer.<init>(Producer.scala:26)
at my.class.blah.blah (KafkaLib.java:60)
at java.lang.Thread.run(Thread.java:745)

I used the maven pom dependency mostly the same except to match what kafka
package I had locally:

<dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.10</artifactId>
            <version>0.8.2.1</version>
            ...
</dependency>

any idea what is the problem for me? Am I supposed to use a different class
than SimplePartitioner for partitioner class config?

I had assumed with boilerplate code, it should work fine. If the code is
executed sequentially top down order, the kafka serializer class is listed
first as a property config, so it seems that was found ok by Java,
otherwise, I assume Java failed finding SimplePartitioner before it could
even fail looking for the serializer.

Reply via email to