# \[kafka\] \[java.lang.ClassNotFoundException\] overriding partitioner\_class

**URL:** <https://discuss.elastic.co/t/kafka-java-lang-classnotfoundexception-overriding-partitioner-class/28527>\
**Category:** Logstash\
**Created:** [September 2, 2015, 1:46pm UTC](https://discuss.elastic.co/t/kafka-java-lang-classnotfoundexception-overriding-partitioner-class/28527 "2015-09-02T13:46:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steotia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steotia/32/4542_2.png) [@steotia](https://discuss.elastic.co/u/steotia)\
**Post date:** [September 2, 2015, 1:46pm UTC](https://discuss.elastic.co/t/kafka-java-lang-classnotfoundexception-overriding-partitioner-class/28527/1 "2015-09-02T13:46:04Z")

</div>

I created a partitioner\_class and replaced the partitioner\_class appropriately in the conf file. The jar containing the partitioner\_class was added to the CLASSPATH.

However, when I started logstash, logstash errored out with a trace I have appended at the end of this comment.

The only way I can avoid the error is if I create a fat jar (jar-with-dependencies) for the partitioner\_class, even though all the dependencies are included in the plugin.

Is this expected? I was under the impression that all that was required was to create a jar containing the relevant file and include that in the CLASSPATH.

```
  ava/lang/ClassLoader.java:-2:in `defineClass1': java.lang.NoClassDefFoundError: kafka/producer/Partitioner
    from java/lang/ClassLoader.java:800:in `defineClass'
    from java/security/SecureClassLoader.java:142:in `defineClass'
    from java/net/URLClassLoader.java:449:in `defineClass'
   ...
    from <SOME_DIR>/logstash-1.5.4/vendor/bundle/jruby/1.9/gems/stud-0.0.21/lib/stud/task.rb:12:in `initialize'
    from java/lang/Thread.java:745:in `run'
  Caused by:
  URLClassLoader.java:366:in `run': java.lang.ClassNotFoundException: kafka.producer.Partitioner
    from URLClassLoader.java:355:in `run'
    from AccessController.java:-2:in `doPrivileged'
    from URLClassLoader.java:354:in `findClass'
    ...

```

Logstash config was

```
output {
  stdout{}
  kafka {
    broker_list => "localhost:9092"
    topic_id => "test"
    compression_codec => "none"
    compressed_topics => ""
    request_required_acks => 0
    serializer_class => "kafka.serializer.StringEncoder"
    partitioner_class => "org.x.UIDPartitioner"
    request_timeout_ms => 10000
    producer_type => "sync"
    key_serializer_class => "kafka.serializer.StringEncoder"
    message_send_max_retries => 3
    retry_backoff_ms => 100
    topic_metadata_refresh_interval_ms => 600000
    queue_buffering_max_ms => 5000
    queue_buffering_max_messages => 10000
    queue_enqueue_timeout_ms => -1
    batch_num_messages => 200
    send_buffer_bytes => 102400
    client_id => "kafka"
  }
}
```

---

<div class="post-metadata">

**Author:** ![Joe\_Lawson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_lawson/32/3390_2.png) [@Joe\_Lawson](https://discuss.elastic.co/u/Joe_Lawson)\
**Post date:** [September 12, 2015, 7:03pm UTC](https://discuss.elastic.co/t/kafka-java-lang-classnotfoundexception-overriding-partitioner-class/28527/2 "2015-09-12T19:03:40Z")

</div>

Try finding the jar files included in the jruby-kafka plugin distributed  
with logstash and drop the jar there and then update the  
jruby-kafka\_jars.rb file. I think there is some discussion on how to do  
this more easily on github. Did you try what was discussed here:  
[https://github.com/logstash-plugins/logstash-input-kafka/pull/29](https://github.com/logstash-plugins/logstash-input-kafka/pull/29) ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:29am UTC](https://discuss.elastic.co/t/kafka-java-lang-classnotfoundexception-overriding-partitioner-class/28527/3 "2017-07-06T05:29:17Z")

</div>

Closed on July 6, 2017, 5:29am UTC


