1

I downloaded/installed protocol buffers 3.1.0 and used protoc to compile a .proto file which generated a .java class for me.

With this change, everything works/compiles. Then I replaced the avro jars with their latest versions and tried to compile my project again, but no luck, it's complaining this error:

# Compile: pregen/media.proto
pregen/media.proto/serializers/protobuf/media/MediaContentHolder.java:828: error: cannot find symbol
            com.google.protobuf.Descriptors.OneofDescriptor oneof) {
                                           ^
  symbol:   class OneofDescriptor
  location: class Descriptors
pregen/media.proto/serializers/protobuf/media/MediaContentHolder.java:2669: error: cannot find symbol
            com.google.protobuf.Descriptors.OneofDescriptor oneof) {
                                           ^
  symbol:   class OneofDescriptor
  location: class Descriptors
pregen/media.proto/serializers/protobuf/media/MediaContentHolder.java:4131: error: cannot find symbol
            com.google.protobuf.Descriptors.OneofDescriptor oneof) {
                                           ^
  symbol:   class OneofDescriptor
  location: class Descriptors
3 errors

I did a lot search/research and still no luck, also looked at this most relevant post: Problems using protobufs with java and scala and then I compiled my generated .java file along with protobuf.3.1.0.jar into a new jar and placed it under my lib/, but the project still cannot compile.

Any help on how to resolve this issue please?

(I'm using an open-source project to benchmark Java serialzation performance, and I've posted a more detailed question/issue there as well.)

Community
  • 1
  • 1
Fisher Coder
  • 3,278
  • 12
  • 49
  • 84

1 Answers1

3

One of the authors of that open source projects helped me resolve the issue, copy the solution here as well:

"The problem was that avro-tools-1.8.1.jar bundles some of the Protobuf class files (ugh). The bundled class files aren't compatible with the ones our generated Protobuf code relies on.

We're pretty fast and loose with what's on the classpath; we just include "lib/*.jar". It would be nice to be more precise with dependencies at some point.

But as a quick fix, I put avro-tools-1.8.1.jar in "lib/extra/", so it won't get picked up by default. The Makefile now specifically references that JAR only when we need to run the Avro code generator."

Thanks.

Fisher Coder
  • 3,278
  • 12
  • 49
  • 84