grpc-ecosystem / grpc-ecosystem/grpc-spring
local example fails with "java.lang.NoClassDefFoundError: net/devh/boot/grpc/examples/lib/HelloReply$Builder"
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 858
- PR merge metrics
- No merged PRs in 30d
Description
**The context**
Run the local example as described on https://github.com/yidongnan/grpc-spring-boot-starter/tree/master/examples#local-mode
**The bug**
Both services start, but upon calling the webpage, the server throws an
`java.lang.NoClassDefFoundError: net/devh/boot/grpc/examples/lib/HelloReply$Builder`
**Stacktrace and logs**
```
> Task :examples:local-grpc-server:bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.2)
2022-03-10 14:43:53.671 INFO 411577 --- [ main] n.d.b.g.e.l.s.LocalGrpcServerApplication : Starting LocalGrpcServerApplication using Java 1.8.0_312 on dtm2573lapli with PID 411577 (/home/martinsc/java/github/grpc-spring-boot-starter/examples/local-grpc-server/build/classes/java/main started by martinsc in /home/martinsc/java/github/grpc-spring-boot-starter/examples/local-grpc-server)
2022-03-10 14:43:53.679 INFO 411577 --- [ main] n.d.b.g.e.l.s.LocalGrpcServerApplication : No active profile set, falling back to default profiles: default
2022-03-10 14:43:55.949 INFO 411577 --- [ main] g.s.a.GrpcServerFactoryAutoConfiguration : Detected grpc-netty-shaded: Creating ShadedNettyGrpcServerFactory
2022-03-10 14:43:56.653 INFO 411577 --- [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: Simple, bean: grpcServerService, class: net.devh.boot.grpc.examples.local.server.GrpcServerService
2022-03-10 14:43:56.654 INFO 411577 --- [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: grpc.health.v1.Health, bean: grpcHealthService, class: io.grpc.protobuf.services.HealthServiceImpl
2022-03-10 14:43:56.654 INFO 411577 --- [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: grpc.reflection.v1alpha.ServerReflection, bean: protoReflectionService, class: io.grpc.protobuf.services.ProtoReflectionService
2022-03-10 14:43:57.330 INFO 411577 --- [ main] n.d.b.g.s.s.GrpcServerLifecycle : gRPC Server started, listening on address: *, port: 9898
2022-03-10 14:43:57.392 INFO 411577 --- [ main] n.d.b.g.e.l.s.LocalGrpcServerApplication : Started LocalGrpcServerApplication in 5.268 seconds (JVM running for 6.702)
2022-03-10 14:49:52.489 INFO 411577 --- [ault-executor-0] n.d.b.g.e.l.server.LogGrpcInterceptor : Simple/SayHello
Exception in thread "grpc-default-executor-0" java.lang.NoClassDefFoundError: net/devh/boot/grpc/examples/lib/HelloReply$Builder
at net.devh.boot.grpc.examples.lib.HelloReply.toBuilder(HelloReply.java:276)
at net.devh.boot.grpc.examples.lib.HelloReply.newBuilder(HelloReply.java:269)
at net.devh.boot.grpc.examples.local.server.GrpcServerService.sayHello(GrpcServerService.java:36)
at net.devh.boot.grpc.examples.lib.SimpleGrpc$MethodHandlers.invoke(SimpleGrpc.java:232)
at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35)
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23)
at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40)
at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86)
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:340)
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:866)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: net.devh.boot.grpc.examples.lib.HelloReply$Builder
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 16 more
```
**Steps to Reproduce**
Steps to reproduce the behavior:
1. Checkout the project from github
2. Run the steps in "Local Setup"
**The application's environment**
Which versions do you use?
* Spring (boot): as in the repo
* grpc-java: as in the repo
* grpc-spring-boot-starter: as in the repo
* java: version + architecture (64bit?)
```
> java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
```
* Other relevant libraries...
**Additional context**
* Did it ever work before? No
Contributor guide
Assessment
This issue has not been assessed yet.