You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by ab...@ubs.com on 2016/06/14 14:56:50 UTC

unable to serialize / deserliaze org.joda.time.DateTime

Hello,

I'm using Apache Avro 1.8.1 and from what I can understand from this JIRA https://issues.apache.org/jira/browse/AVRO-1672

I can use joda DateTime.

Using the IDL, I can successfully create builders

record ABC {
	Timestamp_ms valDate;
}

and it correctly generates the code that uses joda DateTime.

However, when I try and serialize this (either binary or json), it bombs out with this stack trace.  Any idea what I'm doing wrong?

************************
Unknown datum type org.joda.time.DateTime: 2016-06-14T15:50:08.622+01:00
org.apache.avro.AvroRuntimeException: Unknown datum type org.joda.time.DateTime: 2016-06-14T15:50:08.622+01:00
	at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:741)
	at org.apache.avro.specific.SpecificData.getSchemaName(SpecificData.java:293)
	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:706)
	at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:192)
	at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:110)
	at org.apache.avro.specific.SpecificDatumWriter.writeField(SpecificDatumWriter.java:87)
	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:143)
	at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:105)
	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:60)
************************


Serialization code snippet
************************
      val out = new ByteArrayOutputStream
      val encoder = EncoderFactory.get.binaryEncoder(out, null)
      val writer = new SpecificDatumWriter[T](avro.getSchema)
      writer.write(obj, encoder)
      encoder.flush()
      out.flush()
      out.toByteArray
************************

cheers
Abhay


Visit our website at http://www.ubs.com 

This message contains confidential information and is intended only 
for the individual named. If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail. Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system. 

E-mails are not encrypted and cannot be guaranteed to be secure or 
error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses. The sender 
therefore does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission. 
If verification is required please request a hard-copy version. This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities 
or related financial instruments. 

UBS Limited is a company limited by shares incorporated in the United 
Kingdom registered in England and Wales with number 2035362.  
Registered Office: 1 Finsbury Avenue, London EC2M 2PP
UBS Limited is authorised by the Prudential Regulation Authority 
and regulated by the Financial Conduct Authority and the Prudential 
Regulation Authority.

UBS AG is a public company incorporated with limited liability in
Switzerland domiciled in the Canton of Basel-City and the Canton of
Zurich respectively registered at the Commercial Registry offices in
those Cantons with new Identification No: CHE-101.329.561 as from 18
December 2013 (and prior to 18 December 2013 with Identification
No: CH-270.3.004.646-4) and having respective head offices at
Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich,
Switzerland and is authorised and regulated by the Financial Market
Supervisory Authority in Switzerland.  Registered in the United
Kingdom as a foreign company with No: FC021146 and having a UK
Establishment registered at Companies House, Cardiff, with
No: BR 004507.  The principal office of UK Establishment: 1 Finsbury
Avenue, London EC2M 2PP.  In the United Kingdom, UBS AG is authorised
by the Prudential Regulation Authority and subject to regulation
by the Financial Conduct Authority and limited regulation by the
Prudential Regulation Authority.  Details about the extent of our
regulation by the Prudential Regulation Authority are available
from us on request.

UBS reserves the right to retain all messages. Messages are protected 
and accessed only in legally justified cases.