question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it required to set `java_multiple_files = true` option in proto definition

See original GitHub issue

When I try to build the project without setting java_multiple_files = true option in proto definition, I got Unresolved reference: error. It seems like the generated code referring to message type like <service-name>.<message-name> but there is no java class generated with the service-name.

When I set the java_multiple_files option to true. The code generates correctly and builds successfully.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
daneshkcommented, Apr 20, 2020

I think I found the issue. The problem comes when the proto file name is equal to the service name define inside the proto file. For example: Let say we have a proto file called hello_world.proto and service definition inside the proto file like below

syntax = "proto3";

package io.grpc.examples.helloworld;

// The greeting service definition.
service HelloWorld {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

Here proto filename is hello_world.proto and service name is HelloWorld.

When we generate the code, Generated java class is HelloWorldOuterClass.java. but generated Kotlin file is referring to the HelloWorld.HelloRequest for the message type. which causes the : Unresolved reference: HelloWorld

0reactions
lowassercommented, Apr 21, 2020

Sounds like a valid bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Language Guide | Protocol Buffers - Google Developers
Here's the .proto file you use to define the message type. message SearchRequest { required ... To do this you need to set...
Read more >
proto3: Why setting java_multiple_files = true not creating ...
I have a proto definition with nested classes
Read more >
proto3: Why setting java_multiple_files = true ... - Google Groups
I have a proto definition with nested classes. syntax = "proto3";. option java_package = "com.spot.proto.v1.config";. package v1config;.
Read more >
Extending Protobuf: custom options - Giorgio Azzinnaro
google.protobuf"; option java_outer_classname = "AnyProto"; option java_multiple_files = true; option objc_class_prefix = ...
Read more >
Protobuf Service Descriptors • Akka gRPC - Documentation
gRPC uses the Protobuf .proto file format to define your messages, services and some ... source option java_multiple_files = true; option java_package ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found