---------- Forwarded message ----------
From: "Dana Powers" <dana.pow...@gmail.com>
Date: Feb 9, 2016 7:59 PM
Subject: Re: [kafka-clients] java clients problem
To: "iman teimoornegad" <iman.teimourne...@gmail.com>
Cc:

You should email users@kafka.apache.org . this mailing list is used for
development of third party client libraries.

-Dana
On Feb 9, 2016 5:12 AM, "iman teimoornegad" <iman.teimourne...@gmail.com>
wrote:

> hi i have sample producer in java but i recieve error telling me
> serialization.exception eror
> is there any working producer and consumer java class?
> here is my code:
>
>
> import org.apache.avro.Schema;
> import org.apache.avro.generic.GenericData;
> import org.apache.avro.generic.GenericRecord;
> import org.apache.kafka.clients.producer.KafkaProducer;
> import org.apache.kafka.clients.producer.ProducerRecord;
> import org.apache.kafka.common.errors.SerializationException;
>
> import java.net.UnknownHostException;
> import java.util.Properties;
>
>
> public class AvroProducer {
>
>     public static void main(String[] args) throws UnknownHostException {
>
>
>         Properties props = new Properties();
>         
> props.put(org.apache.kafka.clients.producer.ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
>  "localhost:9092");
>         
> props.put(org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
>  io.confluent.kafka.serializers.KafkaAvroSerializer.class);
>         
> props.put(org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
>  io.confluent.kafka.serializers.KafkaAvroSerializer.class);
>         props.put("schema.registry.url", "http://localhost:8081";);
>         KafkaProducer producer = new KafkaProducer(props);
>
>         String key = "key1";
>         String userSchema = "{\"type\":\"record\"," +
>                 "\"name\":\"myrecord\"," +
>                 "\"fields\":[{\"name\":\"f1\",\"type\":\"string\"}]}";
>         Schema.Parser parser = new Schema.Parser();
>         Schema schema = parser.parse(userSchema);
>         GenericRecord avroRecord = new GenericData.Record(schema);
>         avroRecord.put("f1", "iman");
>
>         ProducerRecord record = new ProducerRecord<Object, 
> Object>("_schemas", key, avroRecord);
>         try {
>             producer.send(record);
>         } catch (SerializationException e) {
>             System.out.printf("fucked up");
>         }
>
>     }
> }
>
>
>
> error :
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/kafka/common/errors/SerializationException
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:195)
>     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.kafka.common.errors.SerializationException
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
>     ... 3 more
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "kafka-clients" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kafka-clients+unsubscr...@googlegroups.com.
> To post to this group, send email to kafka-clie...@googlegroups.com.
> Visit this group at https://groups.google.com/group/kafka-clients.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/kafka-clients/7edc95e6-af00-4ce6-80a2-92f54f1fb60b%40googlegroups.com
> <https://groups.google.com/d/msgid/kafka-clients/7edc95e6-af00-4ce6-80a2-92f54f1fb60b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

Reply via email to