Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc compile fail with google-protobuf #12719

Closed
gaetancollaud opened this issue Oct 14, 2020 · 5 comments · Fixed by #12797
Closed

grpc compile fail with google-protobuf #12719

gaetancollaud opened this issue Oct 14, 2020 · 5 comments · Fixed by #12797
Assignees
Labels
area/grpc gRPC kind/bug Something isn't working
Milestone

Comments

@gaetancollaud
Copy link
Contributor

Describe the bug
I use GRPC and I use to google protobuf like for example timestamp.proto. I'm my other microservices (spring-boot), I easily include the maven dependency com.google.protobuf:protobuf-java and I can use the google proto. But with quarkus it doesn't work out of the box.

Expected behavior
I can include the com.google.protobuf:protobuf-java dependencies and quakurs grpc extension will pick it up automatically.

Actual behavior
Compilation failed with

[INFO] --- quarkus-maven-plugin:1.8.3.Final:generate-code (default) @ grpc-google-protobuf ---
google/protobuf/timestamp.proto: File not found.
hello.proto:7:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
hello.proto:12:5: "google.protobuf.Timestamp" is not defined.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.284 s
[INFO] Finished at: 2020-10-14T16:54:56+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.8.3.Final:generate-code (default) on project grpc-google-protobuf: Prepare phase of the quarkus-maven-plugin threw an error: Failed to generate Java classes from proto files: [/home/gaetan/workspace/github/grpc-google-protobuf/src/main/proto/hello.proto] to /home/gaetan/workspace/github/grpc-google-protobuf/target/generated-sources/grpc -> [Help 1]

To Reproduce

https://github.com/gaetancollaud/grpc-google-protobuf

You can look at the branch protobuf-maven-plugin where I disable the goal generate-code of the quarkus-maven-plugin and where I manually configured the protobuf-maven-plugin. This version works and I can compile, but then mvn quarkus:dev auto reload is broken.

Steps to reproduce the behavior:

  1. Checkout the repo https://github.com/gaetancollaud/grpc-google-protobuf
  2. mvn compile

Configuration
Nothing specific

Screenshots
No screenshot

Environment (please complete the following information):

  • Output of uname -a or ver: Linux gaetan-desktop 5.4.0-48-generic Adjust log colors, and do not log in color if the console is not in color #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version: Java version: 11.0.8, vendor: GraalVM Community, runtime: /home/gaetan/.sdkman/candidates/java/20.2.0.r11-grl
  • GraalVM version (if different from Java): 20.2.0.r11
  • Quarkus version or git rev: 1.8.3
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3

Additional context
No additional context

@gaetancollaud gaetancollaud added the kind/bug Something isn't working label Oct 14, 2020
@quarkusbot quarkusbot added the area/grpc gRPC label Oct 14, 2020
@quarkusbot
Copy link

/cc @michalszynkiewicz, @cescoffier

@michalszynkiewicz michalszynkiewicz self-assigned this Oct 14, 2020
@gaetancollaud
Copy link
Contributor Author

For convenience and to workaround this issue I tried to copy the google proto inside the project itself, but now I have this issue when using StringValue.of:

java.lang.IllegalAccessError: class com.google.protobuf.StringValue$Builder tried to access protected field com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders (
com.google.protobuf.StringValue$Builder is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @587c6af6; 
com.google.protobuf.GeneratedMessageV3 is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @38e3de9e)

Same package, but not same class loader.

So I cannot find any way to make it work with the quarkus auto reload feature. 😞

@michalszynkiewicz
Copy link
Member

I'm currently looking into this issue. I'm a bit surprised that copying the proto files doesn't work.

protobuf-maven-plugin scans classpath and adds *.proto files from all the jars to includes for compilation. I think I need to add the same for the grpc code-gen, possibly with some control that would allow opting out from scanning or scanning only selected dependencies so that the impact on performance is limited.

@michalszynkiewicz
Copy link
Member

@gaetancollaud I created a pull request for it: #12797

@gaetancollaud
Copy link
Contributor Author

Thanks I will have a look

@gsmet gsmet added this to the 1.10 - master milestone Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/grpc gRPC kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants