avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chandrashekhar Kotekar <shekhar.kote...@gmail.com>
Subject How to send Avro data as a response from REST web service?
Date Wed, 06 Aug 2014 07:45:28 GMT

I would like to know what is the best way to convert POJO into Avro type
object and send it as an response from REST web service?

I have managed to do following things :

1. Write avsc files and generate POJO from avsc files.

2. Added Avro data provider using @Provider annotation and extending

3. Wrote following code in writeTo() method of the provider

public void writeTo(Object obj, Class classType, Type type, Annotation[]
MediaType mediaType, MultivaluedMap map, OutputStream outStream) throws
IOException, WebApplicationException {

Encoder encoder = ENCODER_FACTORY.binaryEncoder(outStream, null);
DatumWriter writer = new ReflectDatumWriter();
 writer.write(obj, encoder);

I am getting NullPointerException when writer.write(obj, encoder) method is
called. In stacktrace I am not able to find any clue.

How to resolve this issue? or ss there any other way to send Avro data as a
response from REST service?

Chandrash3khar Kotekar
Mobile - +91 8600011455

View raw message