It's hard to tell without more detail, but I strongly suspect this is
a Camel issue rather than a purely Avro issue.  It might thus better
be asked on the Camel user mailing list.

https://camel.apache.org/mailing-lists.html

Doug

On Tue, Feb 4, 2014 at 8:54 AM, Kostas Margaritis
<[email protected]> wrote:
> Hi all,
>
> after many experiments of using camel-avro, I decided to send an email to the 
> list as I'm getting ClassCastException errors, even with simple schemas.
> Java class from AVRO Schema file (avsc) generation works fine and the 
> resulting class builds and is included in the end project, but I can't really 
> make it work.
> Using Avro 1.7.5, and trying to send messages over jetty (using camel-avro 
> and camel-jetty resp), and using this schema:
>
> {   "namespace" :   "serialisationtests.generated",
>     "type"      :   "record",
>     "name"      :   "TestPacket",
>     "fields"    :   [
>         { "name": "firstname", "type": "string" },
>         { "name": "lastname",  "type": "string" },
>         { "name": "date", "type" : "string" },
>         { "name": "features", "type": {"type": "array", "items": "string"}},
>         { "name": "properties", "type": {"type": "map", "values": "string"}}
>     ]
> }
>
> I then use camel-dataset to produce such objects and then pass them through 
> avro marshalling to a jetty listener.
> This is the exception I'm getting when trying to run mvn test:
>
> -------------------------------------------------------
>  T E S T S
> -------------------------------------------------------
> Running serialisationtests.test.SerialisationTest
> [                          main] SerialisationTest              INFO  
> ********************************************************************************
> [                          main] SerialisationTest              INFO  
> Testing: 
> testReceivedDirectJettyMessages(serialisationtests.test.SerialisationTest)
> [                          main] SerialisationTest              INFO  
> ********************************************************************************
> [                          main] SpringCamelContext             INFO  Apache 
> Camel 2.12.0.redhat-610336 (CamelContext: camel-1) is starting
> [                          main] ManagedManagementStrategy      INFO  JMX is 
> enabled
> [                          main] DefaultTypeConverter           INFO  Loaded 
> 186 type converters
> [                          main] set://myDataSet?produceDelay=0 INFO  
> Endpoint[dataset://myDataSet?produceDelay=0] expecting 6000 messages
> [                          main] SpringCamelContext             INFO  
> StreamCaching is not in use. If using streams then its recommended to enable 
> stream caching. See more details at 
> http://camel.apache.org/stream-caching.html
> [                          main] SpringCamelContext             INFO  Route: 
> route1 started and consuming from: 
> Endpoint[dataset://myDataSet?produceDelay=0]
> [                          main] JettyHttpComponent             WARN  You use 
> localhost interface! It means that no external connections will be available. 
> Don't you want to use 0.0.0.0 instead (all network interfaces)? 
> Endpoint[http://localhost:8888/myservice]
> [                          main] JettyHttpComponent             INFO  Using 
> default Jetty continuation timeout for: 
> Endpoint[http://localhost:8888/myservice]
> [                          main] Server                         INFO  
> jetty-8.1.9.v20130131
> [                          main] AbstractConnector              INFO  Started 
> SelectChannelConnector@localhost:8888
> [                          main] SpringCamelContext             INFO  Route: 
> route2 started and consuming from: Endpoint[http://localhost:8888/myservice]
> [                          main] SpringCamelContext             INFO  Total 2 
> routes, of which 2 is started.
> [                          main] SpringCamelContext             INFO  Apache 
> Camel 2.12.0.redhat-610336 (CamelContext: camel-1) started in 2.611 seconds
> [                          main] MockEndpoint                   INFO  
> Asserting: Endpoint[mock://result-jetty] is satisfied
> [hread #0 - dataset://myDataSet] DefaultErrorHandler            ERROR Failed 
> delivery for (MessageId: ID-pippin-46409-1391532031804-0-1 on ExchangeId: 
> ID-pippin-46409-1391532031804-0-2). Exhausted after delivery attempt: 1 
> caught: java.lang.ClassCastException: java.util.ArrayList$Itr cannot be cast 
> to org.apache.avro.generic.IndexedRecord
>
> Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> RouteId              ProcessorId          Processor                           
>                                              Elapsed (ms)
> [route1            ] [route1            ] [dataset://myDataSet?produceDelay=0 
>                                            ] [        81]
> [route1            ] [marshal1          ] [marshal[ref:avro]                  
>                                            ] [        69]
>
> Exchange
> ---------------------------------------------------------------------------------------------------------------------------------------
> Exchange[
>         Id                  ID-pippin-46409-1391532031804-0-2
>         ExchangePattern     InOnly
>         Headers             {breadcrumbId=ID-pippin-46409-1391532031804-0-1, 
> CamelDataSetIndex=0, CamelRedelivered=false, CamelRedeliveryCounter=0}
>         BodyType            java.util.ArrayList.Itr
>         Body                java.util.ArrayList$Itr@104ff98
> ]
>
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------
> java.lang.ClassCastException: java.util.ArrayList$Itr cannot be cast to 
> org.apache.avro.generic.IndexedRecord
>         at 
> org.apache.avro.generic.GenericData.getField(GenericData.java:576)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.avro.generic.GenericData.getField(GenericData.java:591)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:112)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:66)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:58)[avro-1.7.5.jar:1.7.5]
>         at 
> org.apache.camel.dataformat.avro.AvroDataFormat.marshal(AvroDataFormat.java:124)[camel-avro-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:81)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.component.dataset.DataSetConsumer.sendMessages(DataSetConsumer.java:89)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> org.apache.camel.component.dataset.DataSetConsumer$1.run(DataSetConsumer.java:70)[camel-core-2.12.0.redhat-610336.jar:2.12.0.redhat-610336]
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)[:1.6.0_29]
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.6.0_29]
>         at java.lang.Thread.run(Thread.java:701)[:1.6.0_29]
> [hread #0 - dataset://myDataSet] DefaultErrorHandler            ERROR Failed 
> delivery for (MessageId: ID-pippin-46409-1391532031804-0-3 on ExchangeId: 
> ID-pippin-46409-1391532031804-0-4). Exhausted after delivery attempt: 1 
> caught: java.lang.ClassCastException: java.util.ArrayList$Itr cannot be cast 
> to org.apache.avro.generic.IndexedRecord
>
>
> Any suggestions/solutions appreciated.
>
> Thanks
>
> Kostas Margaritis

Reply via email to