0
votes

I am getting below error when trying to create a newBuilder() object for a given protobuf class. Having protobuf-java-2.4.1.jar in the classpath.

Same is working on the server side but fails on the client.

java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    packagename.QuerySpecProtos$QuerySpec$Builder.clone()Lcom/google/protobuf/AbstractMessageLite$Builder; @4: areturn
  Reason:
    Type 'packagename.QuerySpecProtos$QuerySpec$Builder' (current frame, stack[0]) is not assignable to 'com/google/protobuf/AbstractMessageLite$Builder' (from method signature)
  Current Frame:
    bci: @4
    flags: { }
    locals: { 'packagename.QuerySpecProtos$QuerySpec$Builder' }
    stack: { 'packagename.QuerySpecProtos$QuerySpec$Builder' }
  Bytecode:
    0000000: 2ab6 0062 b0                           
1
What version of protobufs was used when compiling the class? You have to use the same jar version when compiling and running, and you also have to use the same version of protoc to match the jar. - Kenton Varda
@Kenton Thanks for the info. Was using different version of jar during runtime. - Amareswar
OK, I'll turn my comment into an answer, then. :) - Kenton Varda

1 Answers

2
votes

Looks like a version mismatch. You need to be sure that both:

  1. You use the same jar version when compiling and running.
  2. You use the same version of protoc to match the jar.