Quarkus gRPC client injection

464 Views Asked by At

I'm trying to inject my grpc service via @GrpcClient as it is written in the documentation and have runtime NullPointerException when I call an endpoint on my client microservice because "Unsatisfied dependency: no bean matches the injection point". If I instantiate mutiny stub and channel manually it works as expected. With mvn compile and quarkus.generate-code.grpc.scan-for-imports=all I have done, so generated classes and interfaces exist in target.generated-sources.grpc.<package-name> path.

Data client

class PlatformDataClientImpl {

    // @Inject  with this does not work as well
    @GrpcClient("baz")
    GrpcPlatform baz;

    public Uni<List<Platform>> getAllPlatforms() {
        return baz
            .getAllPlatforms(PlatformProto.GetAllRequest.newBuilder().build())
            .onItem()
            .transform(platformResponse -> platformResponse
                .getPlatformList()
                .stream()
                .map(this::transformPlatform)
                .collect(Collectors.toList())
            );
    }
}

Traceback

2022-07-09 14:03:25,390 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-1) Request failed: java.lang.NullPointerException: Cannot invoke "com.kahnwald.command.GrpcPlatform.getAllPlatforms(com.kahnwald.command.PlatformProto$GetAllRequest)" because "this.baz" is null
at com.kahnwald.command.data.clients.PlatformDataClientImpl.getAllPlatforms(PlatformDataClientImpl.java:21)
at com.kahnwald.command.ExampleResource.gTest(ExampleResource.java:28)
at com.kahnwald.command.ExampleResource_Subclass.gTest$$superforward1(Unknown Source)
at com.kahnwald.command.ExampleResource_Subclass$$function$$1.apply(Unknown Source)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
at com.kahnwald.command.ExampleResource_Subclass.gTest(Unknown Source)
at com.kahnwald.command.ExampleResource$quarkusrestinvoker$gTest_3bdd2c95d9fa1dda6e9fab2c52cbe4fe8e995401.invoke(Unknown Source)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:108)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
at org.jboss.resteasy.reactive.server.handlers.RestInitialHandler.beginProcessing(RestInitialHandler.java:49)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:17)
at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveVertxHandler.handle(ResteasyReactiveVertxHandler.java:7)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:83)
at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:67)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:126)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141)
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:274)
at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

Could anybody describe what I missed or do wrong? Do I need to implement services on client side or something?

Quarkus version: 2.9.2.Final

0

There are 0 best solutions below