Open ranjanashish opened 2 years ago
/cc @glefloch, @quarkusio/devtools
CC: @cescoffier
It could be a very useful feature, is there any progress?
Proto generation is handled by Quarkus itself. If plugins are required, disable Quarkus generation and use the plugin you want.
@cescoffier if Proto Generation is handled by Quarkus itself, is there any other way of adding validation to the input without any extra plugins
No, but contributions are more than welcome!
Hi!
It is interesting that build.buf:protovalidate:0.2.1
works as expected
quarkus.generate-code.grpc.scan-for-imports=com.google.api.grpc:proto-google-common-protos,com.google.protobuf:protobuf-java,build.buf:protovalidate
try {
ValidationResult result = validator.validate(request);
// Check if there are any validation violations
if (result.getViolations().isEmpty()) {
// No violations, validation successful
System.out.println("Validation succeeded");
} else {
// Print the violations if any found
System.out.println(result.toString());
}
} catch (ValidationException e) {
// Catch and print any ValidationExceptions thrown during the validation process
System.out.println("Validation failed: " + e.getMessage());
}
While newer versions throw error:
2024-11-01 12:10:46,829 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.grpc.deployment.devui.GrpcDevUIProcessor#collectMessagePrototypes threw an exception: java.lang.NoClassDefFoundError: com/google/protobuf/RuntimeVersion$RuntimeDomain
at build.buf.validate.ValidateProto.<clinit>(ValidateProto.java:11)
at org.acme.HelloGrpcProto.<clinit>(HelloGrpcProto.java:34)
at org.acme.HelloRequest.internalGetFieldAccessorTable(HelloRequest.java:35)
at com.google.protobuf.GeneratedMessageV3.getDescriptorForType(GeneratedMessageV3.java:116)
at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:735)
at com.google.protobuf.util.JsonFormat$Printer.appendTo(JsonFormat.java:344)
at com.google.protobuf.util.JsonFormat$Printer.print(JsonFormat.java:354)
at io.quarkus.grpc.deployment.devui.GrpcDevUIProcessor.collectMessagePrototypes(GrpcDevUIProcessor.java:119)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at java.base/java.lang.Thread.run(Thread.java:1570)
at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.RuntimeVersion$RuntimeDomain
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:569)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:517)
... 18 more
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:354)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:272)
at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:62)
at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:89)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:428)
at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:55)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:138)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:93)
at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.grpc.deployment.devui.GrpcDevUIProcessor#collectMessagePrototypes threw an exception: java.lang.NoClassDefFoundError: com/google/protobuf/RuntimeVersion$RuntimeDomain
at build.buf.validate.ValidateProto.<clinit>(ValidateProto.java:11)
at org.acme.HelloGrpcProto.<clinit>(HelloGrpcProto.java:34)
at org.acme.HelloRequest.internalGetFieldAccessorTable(HelloRequest.java:35)
at com.google.protobuf.GeneratedMessageV3.getDescriptorForType(GeneratedMessageV3.java:116)
at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:735)
at com.google.protobuf.util.JsonFormat$Printer.appendTo(JsonFormat.java:344)
at com.google.protobuf.util.JsonFormat$Printer.print(JsonFormat.java:354)
at io.quarkus.grpc.deployment.devui.GrpcDevUIProcessor.collectMessagePrototypes(GrpcDevUIProcessor.java:119)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at java.base/java.lang.Thread.run(Thread.java:1570)
at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.RuntimeVersion$RuntimeDomain
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:569)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:517)
... 18 more
at io.quarkus.builder.Execution.run(Execution.java:124)
at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:161)
at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:350)
... 9 more
Caused by: java.lang.NoClassDefFoundError: com/google/protobuf/RuntimeVersion$RuntimeDomain
at build.buf.validate.ValidateProto.<clinit>(ValidateProto.java:11)
at org.acme.HelloGrpcProto.<clinit>(HelloGrpcProto.java:34)
at org.acme.HelloRequest.internalGetFieldAccessorTable(HelloRequest.java:35)
at com.google.protobuf.GeneratedMessageV3.getDescriptorForType(GeneratedMessageV3.java:116)
at com.google.protobuf.util.JsonFormat$PrinterImpl.print(JsonFormat.java:735)
at com.google.protobuf.util.JsonFormat$Printer.appendTo(JsonFormat.java:344)
at com.google.protobuf.util.JsonFormat$Printer.print(JsonFormat.java:354)
at io.quarkus.grpc.deployment.devui.GrpcDevUIProcessor.collectMessagePrototypes(GrpcDevUIProcessor.java:119)
at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733)
at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at java.base/java.lang.Thread.run(Thread.java:1570)
at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.RuntimeVersion$RuntimeDomain
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:569)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:517)
... 18 more
Trying to investigate
UPD it works for newer version of protobuf-java
pom.xm
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>4.28.3</version>
</dependency>
build.gradle.kts
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "com.google.protobuf" && requested.name == "protobuf-java") {
useVersion("4.28.3")
because("Enforcing protobuf-java version to 4.28.3 for buf.build:protovaliate")
}
}
}
Protobuf 4 breaks several things. We do not have support for it yet.
Thanks for your reply! Do you happen to have a list of known issues or things that aren’t working with Protobuf 4?
Description
Currently, Quarkus does not provide the functionality to include extra protoc plugins when using Gradle.
Example plugin - https://github.com/envoyproxy/protoc-gen-validate#java.
Related discussion: https://github.com/quarkusio/quarkus/discussions/27278
Implementation ideas
No response