title: Class org.apache.kafka.common.serialization.StringSerializer not found
body: <p>I wrote a Kafka producer that runs well when I execute it in anyplace besides Spring-XD daemon.</p>
  
  <pre><code>private Properties setProperties () {
      Properties props = new Properties();
      props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,this.getBrokerList());
      props.put(ProducerConfig.ACKS_CONFIG,this.getAcks());
      props.put(ProducerConfig.BATCH_SIZE_CONFIG, this.getBatchSize());
      props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, this.getCompressionCodec());
      props.put(ProducerConfig.RETRIES_CONFIG,this.getRetries());
      props.put(ProducerConfig.LINGER_MS_CONFIG,this.getLinger());
      props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,this.getKeySerializer());
      props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,this.getValueSerializer());
      props.put(ProducerConfig.BUFFER_MEMORY_CONFIG,this.getBufferMemoryConfig());
      return props;
  }
  </code></pre>
  
  <p>When I try to run on Spring-XD as a job I get the following error:</p>
  
  <pre><code>2017-08-15T21:40:05+0000 1.2.1.RELEASE ERROR pool-11-thread-8 consumer.RabbitMQSource - foo-rabbitmq-kafka
  org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.StringSerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.StringSerializer could not be found.
      at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:715) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.common.config.ConfigDef.parseValue(ConfigDef.java:460) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:453) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.common.config.AbstractConfig.&lt;init&gt;(AbstractConfig.java:62) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.common.config.AbstractConfig.&lt;init&gt;(AbstractConfig.java:75) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.clients.producer.ProducerConfig.&lt;init&gt;(ProducerConfig.java:359) ~[kafka-clients-0.11.0.0.jar!/:na]
      at org.apache.kafka.clients.producer.KafkaProducer.&lt;init&gt;(KafkaProducer.java:287) ~[kafka-clients-0.11.0.0.jar!/:na]
      at com.foo.dsat.producer.KafkaSink.getProducer(KafkaSink.java:54) ~[foo-rabbit.jar!/:na]
      at com.foo.dsat.producer.KafkaSink.sendMessage(KafkaSink.java:62) ~[foo-rabbit.jar!/:na]
      at com.foo.dsat.consumer.RabbitMQSource$2.handleDelivery(RabbitMQSource.java:90) ~[foo-rabbit.jar!/:na]
      at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149) [amqp-client-4.2.0.jar!/:na]
      at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:100) [amqp-client-4.2.0.jar!/:na]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
      at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
  2017-08-15T21:40:05+0000 1.2.1.RELEASE ERROR pool-11-thread-8 consumer.RabbitMQSource - foo-rabbitmq-kafka
  org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.StringSerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.StringSerializer could not be found.
  </code></pre>
  
  <p>I saw a solution for this problem, in other StackOverflow topic,</p>
  
  <pre><code>Thread.currentThread().setContextClassLoader(null);
  </code></pre>
  
  <p>But when I try it I get other weird error:</p>
  
  <pre><code>Could not load 'org-xerial-snappy.properties' from classpath:
  java.lang.NullPointerException
  </code></pre>
  
  <p>I found this error on Google but was related to older Kafka versions, which isn't mine.</p>
  
  <pre><code>compile group: 'org.apache.kafka', name: 'kafka_2.12', version: '0.11.0.0'
  </code></pre>
  
  <p>Any suggestion ?</p>