Hi,
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
MessageBodyWriter
3. Wrote following code in writeTo() method of the provider
@Override
public void writeTo(Object obj, Class classType, Type type, Annotation[]
annotations,
MediaType mediaType, MultivaluedMap map, OutputStream outStream) throws
IOException, WebApplicationException {
Encoder encoder = ENCODER_FACTORY.binaryEncoder(outStream, null);
DatumWriter writer = new ReflectDatumWriter();
writer.write(obj, encoder);
encoder.flush();
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?
Regards,
Chandrash3khar Kotekar
Mobile - +91 8600011455
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
MessageBodyWriter
3. Wrote following code in writeTo() method of the provider
@Override
public void writeTo(Object obj, Class classType, Type type, Annotation[]
annotations,
MediaType mediaType, MultivaluedMap map, OutputStream outStream) throws
IOException, WebApplicationException {
Encoder encoder = ENCODER_FACTORY.binaryEncoder(outStream, null);
DatumWriter writer = new ReflectDatumWriter();
writer.write(obj, encoder);
encoder.flush();
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?
Regards,
Chandrash3khar Kotekar
Mobile - +91 8600011455