javamavendependencies

Which dependency am I missing that java cannot find AvroCoder?


I have a project where I use Avro, and I get this error when compiling with maven:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project some-project: Compilation failure
[ERROR] ...some-file.java:[14,34] cannot find symbol
[ERROR] symbol: class AvroCoder
[ERROR] location: package org.apache.beam.sdk.coders

I found the class definition, but I do not really see which module it is defined in. Also that manual does not seem to document how to add a dependency for a specific class (or I missed it).

Here are the two avro dependencies I currently use:

<dependency>
    <groupId>org.apache.avro</groupId>
    <artifactId>avro</artifactId>
    <version>1.11.3</version>
</dependency>
<dependency>
    <groupId>org.apache.avro</groupId>
    <artifactId>avro-compiler</artifactId>
    <version>1.11.3</version>
</dependency>

Do I need more to avoid this cannot find symbol error?


Update:

List of import ...:

import org.apache.avro.Schema;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.SeekableByteArrayInput;
import org.apache.avro.file.SeekableInput;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.DatumReader;

Solution

  • AvroCoder is part of Apache Beam and so you will need to add that to your Maven pom.xml:

    
    <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-extensions-avro</artifactId>
        <version>2.63.0</version>
    </dependency>
    

    though I'll admit that I can't test this in my environment.