grpc-ecosystem / grpc-spring

Spring Boot starter module for gRPC framework.
https://grpc-ecosystem.github.io/grpc-spring/
Apache License 2.0
3.41k stars 808 forks source link

how to can exclude grpc-inprocess #1097

Open shalk opened 2 months ago

shalk commented 2 months ago

The context

What do you wish to achieve?

I want to exclude grpc-inprocess in client.

    <dependency>
      <groupId>net.devh</groupId>
      <artifactId>grpc-client-spring-boot-starter</artifactId>
      <version>3.1.0.RELEASE</version>
      <exclusions>
        <exclusion>
          <artifactId>grpc-inprocess</artifactId>
          <groupId>io.grpc</groupId>
        </exclusion>
      </exclusions>
    </dependency>

The bug

What's the problem? What's not working? What do you expect to happen.

when i run my App, it will fail with Exception.

Because the InProcessChannelFactory is hard code into GrpcClientAutoConfiguration.

Stacktrace and logs

Is there a stacktrace or a hint in the logs? (very important) Screenshots work as well, but don't screenshot your logs.

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.devh.boot.grpc.client.channelfactory.GrpcChannelFactory]: Factory method 'shadedNettyGrpcChannelFactory' threw exception with message: io/grpc/inprocess/InProcessChannelBuilder
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
    ... 36 common frames omitted
Caused by: java.lang.NoClassDefFoundError: io/grpc/inprocess/InProcessChannelBuilder
    at net.devh.boot.grpc.client.autoconfigure.GrpcClientAutoConfiguration.shadedNettyGrpcChannelFactory(GrpcClientAutoConfiguration.java:160)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
    ... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.grpc.inprocess.InProcessChannelBuilder
    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)
    ... 43 common frames omitted

Steps to Reproduce

Steps to reproduce the behavior:

  1. create spring boot App with stub client
  2. exclude grpc-inprocess
  3. run the App

The application's environment

Which versions do you use?

Additional context