crunch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabriel Reid (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CRUNCH-442) Trying to read specific avros, getting ClassCastException
Date Tue, 08 Jul 2014 06:47:34 GMT

    [ https://issues.apache.org/jira/browse/CRUNCH-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14054577#comment-14054577
] 

Gabriel Reid commented on CRUNCH-442:
-------------------------------------

This was fixed in CRUNCH-289, but it looks like it broke shortly thereafter (for the default
situation) in CRUNCH-293. Unfortunately, it's difficult (nearly impossible) to test this one
in automated testing because it would require a lot of messing around with class loaders.

I think that it should work for now if you make the following call before you attempt to materialize
your PCollection:
{code}AvroMode.setSpecificClassLoader(MySpecificAvro.class.getClassLoader());{code}

Can you confirm that that solves it?

In any case, I don't think it should be necessary to make that call explicitly, so I'll try
to put something together to make this work without the explicit setSpecificClassLoader call.




> Trying to read specific avros, getting ClassCastException
> ---------------------------------------------------------
>
>                 Key: CRUNCH-442
>                 URL: https://issues.apache.org/jira/browse/CRUNCH-442
>             Project: Crunch
>          Issue Type: Bug
>          Components: IO
>    Affects Versions: 0.10.0
>            Reporter: Jason Gauci
>
> I have code that looks like this:
> 		ArrayList<MySpecificAvro> data = Lists.newArrayList(pipeline.read(From.avroFile(
> 				"/user/jgauci/data.avro",
> 				Avros.specifics(MySpecificAvro.class))).materialize());
> 		for (MySpecificAvro msa : data) {
> 			System.out.println(msa.getName());
> 		}
> And I get this error:
> Exception in thread "main" java.lang.ClassCastException: org.apache.avro.generic.GenericData$Record
cannot be cast to MySpecificAvro
> The error fires inside the for loop after the materialize has completed.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message