java.lang.ClassNotFoundException: io.grpc.services.HealthStatusManager

See original GitHub issue

The context

Create a gRPC server using grpc-spring-boot-starter library.

The bug

Even when grpc.server.healthServiceEnabled=false, GrpcServerAutoConfiguration tries to create a HealthStatusManager, which fails with a ClassNotFoundException if io.grpc:grpc-services is not on the classpath. Now, if the application has indicated that it doesn’t want to enable health service, there’s no reason for it to add an unnecessary jar on the classpath that is “secretly” needed by the grpc-spring-boot-starter library.

My suggestion is to check for the presence of the class, as well as the property grpc.server.healthServiceEnabled, before creating the HealthStatusManager.

Stacktrace and logs

java.lang.IllegalStateException: Error processing condition on net.devh.boot.grpc.server.autoconfigure.GrpcServerAutoConfiguration.defaultGrpcServerProperties
	at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
	at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
	...
Caused by: java.lang.IllegalStateException: Failed to introspect Class [net.devh.boot.grpc.server.autoconfigure.GrpcServerAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@9e89d68]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
	...
Caused by: java.lang.NoClassDefFoundError: io/grpc/services/HealthStatusManager
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	...
Caused by: java.lang.ClassNotFoundException: io.grpc.services.HealthStatusManager
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	...

Steps to Reproduce

N/A

The application’s environment

Which versions do you use?

  • Spring (boot): 2.3.1.RELEASE
  • grpc-java: 1.30.2
  • grpc-spring-boot-starter: 2.9.0.RELEASE

Additional context

  • Did it ever work before? No
  • Do you have a demo? No

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
asarkarcommented, Feb 7, 2021

Same applies for reflection service. There’s a good reason they are in a separate dependency jar, separation of concerns.

0reactions
ST-DDTcommented, Feb 7, 2021

I will refactor the related code and remove the health manager from it. I just ran into it during my tests…

Read more comments on GitHub >

github_iconTop Results From Across the Web

HealthStatusManager (grpc-all 1.51.0 API)
A health check service is created in the constructor of HealthStatusManager , and it can be retrieved by the getHealthService() method. The health...
Read more >
How to resolve java.lang.NoClassDefFoundError: io/grpc ...
I am new to temporal and exploring its basic,I tried running the basic java but getting the following exception "java.lang.NoClassDefFoundError: ...
Read more >
io.grpc.internal.BaseDnsNameResolverProvider when trying ...
v2.BigtableDataClient]: Factory method 'bigtableDataClient' threw exception; nested exception is java.lang.NoClassDefFoundError: io/grpc/ ...
Read more >
io.grpc.services.HealthStatusManager Java Examples
This page shows Java code examples of io.grpc.services.HealthStatusManager.
Read more >
io.grpc.services.HealthStatusManager.clearStatus java code ...
Best Java code snippets using io.grpc.services.HealthStatusManager.clearStatus (Showing top 4 results out of 315). origin: LogNet/grpc-spring-boot-starter ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found