Version problems?

70 views
Skip to first unread message

Ingolfur Hjorleifsson

unread,
Oct 28, 2024, 10:06:44 AM10/28/24
to grpc.io
Can anyone give tips what is the problem here when compiling on mac?

using protoc —version = libprotoc 28.3
javac  —version= javac 21.0.5
grpc version = protoc-gen-grpc-java-1.41.0-osx-x86_64.exe 

Simple hello world .proto file:

// Copyright 2024 The gRPC Authors

syntax = "proto3";
option java_multiple_files = true;
option objc_class_prefix = "HLW";
package org.baeldung.grpc;

message HelloRequest {
    string firstName = 1;
    string lastName = 2;
}

message HelloResponse {
    string greeting = 1;
}

service HelloService {
    rpc hello(HelloRequest) returns (HelloResponse);
}

javac errors:

javac -d . -cp "jar_lib4/*":. org/baeldung/grpc/org/baeldung/grpc/*.java

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:139: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(firstName_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:142: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(lastName_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:154: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(firstName_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:157: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(lastName_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:427: error: method parseUnknownField in class com.google.protobuf.GeneratedMessage.Builder<BuilderType> cannot be applied to given types;

              if (!super.parseUnknownField(input, extensionRegistry, tag)) {

                        ^

  required: CodedInputStream,com.google.protobuf.UnknownFieldSet.Builder,ExtensionRegistryLite,int

  found:    CodedInputStream,ExtensionRegistryLite,int

  reason: actual and formal argument lists differ in length

  where BuilderType is a type-variable:

    BuilderType extends com.google.protobuf.GeneratedMessage.Builder<BuilderType> declared in class com.google.protobuf.GeneratedMessage.Builder

org/baeldung/grpc/org/baeldung/grpc/HelloResponse.java:99: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(greeting_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloResponse.java:111: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(greeting_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage

org/baeldung/grpc/org/baeldung/grpc/HelloResponse.java:363: error: method parseUnknownField in class com.google.protobuf.GeneratedMessage.Builder<BuilderType> cannot be applied to given types;

              if (!super.parseUnknownField(input, extensionRegistry, tag)) {

                        ^

  required: CodedInputStream,com.google.protobuf.UnknownFieldSet.Builder,ExtensionRegistryLite,int

  found:    CodedInputStream,ExtensionRegistryLite,int

  reason: actual and formal argument lists differ in length

  where BuilderType is a type-variable:

    BuilderType extends com.google.protobuf.GeneratedMessage.Builder<BuilderType> declared in class com.google.protobuf.GeneratedMessage.Builder

org/baeldung/grpc/org/baeldung/grpc/HelloServiceOuterClass.java:70: error: cannot find symbol

    descriptor.resolveAllFeaturesImmutable();

              ^

  symbol:   method resolveAllFeaturesImmutable()

  location: variable descriptor of type FileDescriptor

9 errors



Eric Anderson

unread,
Oct 30, 2024, 10:08:12 AM10/30/24
to Ingolfur Hjorleifsson, grpc.io
On Mon, Oct 28, 2024 at 7:06 AM Ingolfur Hjorleifsson <hingo...@gmail.com> wrote:
using protoc —version = libprotoc 28.3

The version of protobuf-java must be at least the version of protoc being used. protoc 28.3 needs protobuf-java 4.28.3+ (the protobuf release is the minor+patch versions of protobuf-java). So you should depend on protobuf-java 4.28.3+. gRPC right now is depending on 3.x series (but compatible with 4.x), as we wait for the ecosystem to be ready to upgrade to 4.x.
 
grpc version = protoc-gen-grpc-java-1.41.0-osx-x86_64.exe

That is quite old.

javac -d . -cp "jar_lib4/*":. org/baeldung/grpc/org/baeldung/grpc/*.java

org/baeldung/grpc/org/baeldung/grpc/HelloRequest.java:139: error: cannot find symbol

    if (!com.google.protobuf.GeneratedMessage.isStringEmpty(firstName_)) {

                                             ^

  symbol:   method isStringEmpty(Object)

  location: class GeneratedMessage



HelloRequest is a message, which can clue you in to looking at your protobuf versions.
Reply all
Reply to author
Forward
0 new messages