user6088291
user6088291

Reputation:

Protocal buffers aren't generating service stubs

I'm having some trouble generating stubs from my .proto file in GRPC. Here's what the .proto file looks like

`syntax = "proto3";`
// The greeting service definition.
service Greeter {
    // 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;
}

The file does generate protocal buffer code, but I'm not getting any service stubs out of it. I.E. I can't use blocking stubs.

I attempted to use the "java_multiple_files=true" fix, but this just splits the generated proto file into a few separate proto files.

I'm currently using the following command prompt line to generate my proto files.

protoc --proto_path= src\proto\protoFile.proto --java_out=src\sourceThings

Let me know if you have any ideas, or need any more information.

Thanks! -DJ

Upvotes: 7

Views: 3578

Answers (1)

Kenton Varda
Kenton Varda

Reputation: 45171

To get gRPC stubs, you need to tell protoc to use the gRPC plugin, like:

protoc --java_out=src/sourceThings --grpc-java_out=src/sourceThings

You'll need to make sure that the program protoc-gen-grpc-java is in your PATH, or you'll need to specify its location using a flag like:

--plugin=protoc-gen-grpc-java=path/to/protoc-gen-grpc-java

See: https://github.com/grpc/grpc-java/tree/master/compiler

Upvotes: 9

Related Questions