1 year ago

#349591

test-img

HoppyPanda

Java ManagedChannelProvider$ProviderNotFoundException

I have a requirement where we want to only build the ManagedChannel once & reuse it every time the stub makes a rpc call. I am using dagger for DI & I have been getting exceptions whenever I try to build my ManagedChannelBuilder inside the module method.

Code:

@Provides
@Singleton
public AddressClient getAddressClient(){
 return new AddressClient(ManagedChannelBuilder.forAddress("host, "port").usePlaintext().build());
}

Exception in thread "main" io.grpc.ManagedChannelProvider$ProviderNotFoundException: No functional channel service provider found. Try adding a dependency on the grpc-okhttp, grpc-netty, or grpc-netty-shaded artifact web_1 | at io.grpc.ManagedChannelProvider.provider(ManagedChannelProvider.java:43) web_1 | at io.grpc.ManagedChannelBuilder.forAddress(ManagedChannelBuilder.java:39)

And when I try to build the channel inside my class AddressClient(), the application starts seamlessly.

Note: I have seen some examples on SO but mostly the answers are to add corresponding dependencies. IMO this shouldn't be a dependency issue as the app starts when I follow Approach2 to built my ManagedChannel.

grpc

dagger

grpc-java

0 Answers

Your Answer

Accepted video resources