avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S G <sg.online.em...@gmail.com>
Subject Re: UnresolvedUnionException
Date Mon, 03 Nov 2014 20:36:25 GMT
Hi Nick,

This might due to XMLGregorianCalendar not being supported as a data-type
in Avro.
Could you try using some other data-type (recommend using a String at
first, before moving on to a more complex data type)?

You might also want to see https://issues.apache.org/jira/browse/AVRO-739

-SG

On Mon, Nov 3, 2014 at 12:24 PM, Nick Beenham <nick.beenham@gmail.com>
wrote:

> Hi all,
>
> I'm trying to resolve another exception... currently my code looks like:
>
>     @XmlElement(name = "TriggerDate")
>     @XmlSchemaType(name = "date")
>     protected XMLGregorianCalendar triggerDate;
>     @XmlElement(name = "TriggerTime")
>     @XmlSchemaType(name = "time")
>     protected XMLGregorianCalendar triggerTime;
>
>
> public void sendMessage(Msg msg) throws IOException {
>  log.debug("Entering test message send...");
> ReflectData reflectData = ReflectData.AllowNull.get();
> Schema schema = reflectData.getSchema(Msg.class);
>     DatumWriter<Msg> writer = new ReflectDatumWriter<Msg>(schema);
>     ByteArrayOutputStream os = new ByteArrayOutputStream();
>
>     Encoder encoder = EncoderFactory.get().binaryEncoder(os, null);
>         writer.write(msg, encoder);
>         encoder.flush();
>         os.close();
>         KeyedMessage<String, byte[]> data = new KeyedMessage<String,
> byte[]>(TOPIC_NAME, os.toByteArray());
>
>         producer.send(data);
>  }
>
> and I'm getting the following exception:
>
> org.apache.avro.UnresolvedUnionException: Not in union
> ["null",{"type":"record","name":"XMLGregorianCalendar","namespace":"javax.xml.datatype","fields":[]}]:
> 2014-10-22
>
> Any ideas?
>
> Nick
>
>
>

Mime
View raw message