Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot be cast to org.apache.avro.generic.GenericRecord

Tags:

java

avro

I have the autogenerated Agr.java schema file from avro. And I am seeing this error when attempting to cast to a GenericRecord.

(FileStreamer.java:processFile(181)) - java.lang.ClassCastException: records.Agr cannot be cast to org.apache.avro.generic.GenericRecord

It gets thrown from here--

Class avroClass = Class.forName("records.Agr");

GenericRecord avroClassObject = (GenericRecord) avroClass.newInstance();

I am able to run this successfully on the server but not locally on my windows machine. I am using the same build/.pom/etc.

Any insights would be appreciated

like image 918
Nathan Ronsse Avatar asked Jul 19 '26 23:07

Nathan Ronsse


1 Answers

The issue was with my IDE setup, I needed to specify the classpath of the module in the run configuration.

like image 122
Nathan Ronsse Avatar answered Jul 21 '26 13:07

Nathan Ronsse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!