You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The service start well. grpcurl --plaintext -d '{"name": "test"}' localhost:9787 com.example.grpc_nacos.idl.HelloService.SayHello.
But it is not registered in Nacos.
Stacktraces and logs
The service start well.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.4)
2024-11-20T17:07:22.973+08:00 INFO 45706 --- [cloud-grpc-server] [ main] c.e.grpc_nacos.GrpcNacosApplication : Starting GrpcNacosApplication using Java 17.0.13 with PID 45706 (/Users/joe/Source/demo/grpc-nacos/target/classes started by joe in /Users/joe/Source/demo/grpc-nacos)
2024-11-20T17:07:22.975+08:00 INFO 45706 --- [cloud-grpc-server] [ main] c.e.grpc_nacos.GrpcNacosApplication : No active profile set, falling back to 1 default profile: "default"
2024-11-20T17:07:23.302+08:00 INFO 45706 --- [cloud-grpc-server] [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=eeec87e2-94aa-3e0f-9fa7-c6321e3276ea
2024-11-20T17:07:23.395+08:00 INFO 45706 --- [cloud-grpc-server] [ main] g.s.a.GrpcServerFactoryAutoConfiguration : Detected grpc-netty-shaded: Creating ShadedNettyGrpcServerFactory
2024-11-20T17:07:23.530+08:00 INFO 45706 --- [cloud-grpc-server] [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: com.example.grpc_nacos.idl.HelloService, bean: helloService, class: com.example.grpc_nacos.service.HelloService
2024-11-20T17:07:23.530+08:00 INFO 45706 --- [cloud-grpc-server] [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: grpc.health.v1.Health, bean: grpcHealthService, class: io.grpc.protobuf.services.HealthServiceImpl
2024-11-20T17:07:23.530+08:00 INFO 45706 --- [cloud-grpc-server] [ main] n.d.b.g.s.s.AbstractGrpcServerFactory : Registered gRPC service: grpc.reflection.v1alpha.ServerReflection, bean: protoReflectionService, class: io.grpc.protobuf.services.ProtoReflectionService
2024-11-20T17:07:23.589+08:00 INFO 45706 --- [cloud-grpc-server] [ main] n.d.b.g.s.s.GrpcServerLifecycle : gRPC Server started, listening on address: *, port: 4485
2024-11-20T17:07:23.604+08:00 INFO 45706 --- [cloud-grpc-server] [ main] c.e.grpc_nacos.GrpcNacosApplication : Started GrpcNacosApplication in 0.859 seconds (process running for 1.067)
The application's environment
Which versions do you use?
spring-boot: 3.2.4
grpc-java: 1.63.0
grpc-spring-boot-starter: 3.1.0.RELEASE
protobuf: 3.25.2
spring-cloud-alibab: 2023.0.1.0
java: openjdk version "17.0.13" 64-Bit
nacos: 2.3.2
How to reproduce
Just write a HelloService Demo.
Additional Infomation
If I add spring-boot-web-starter in dependencies, the server fail to start.
2024-11-20T20:22:55.062+08:00 ERROR 19203 --- [cloud-grpc-server] [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Exception starting filter [requestContextFilter]
java.lang.NoClassDefFoundError: jakarta/annotation/PostConstruct
at org.apache.catalina.core.DefaultInstanceManager.findPostConstruct(DefaultInstanceManager.java:640) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(DefaultInstanceManager.java:341) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:164) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:157) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:101) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4287) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4902) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:845) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:240) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:921) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:105) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:499) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:218) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618) ~[spring-context-6.1.5.jar:6.1.5]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.4.jar:3.2.4]
at com.example.grpc_nacos.GrpcNacosApplication.main(GrpcNacosApplication.java:13) ~[classes/:na]
Caused by: java.lang.ClassNotFoundException: jakarta.annotation.PostConstruct
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[na:na]
... 43 common frames omitted
The error is most likely caused by
<dependency>
<!-- Java 9+ compatibility - Do NOT update to 2.0.0 -->
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
<optional>true</optional>
</dependency>
After the version is downgraded to the following, the service is registered and the gPRC port is displayed.
spring-boot: 2.6.13
grpc-java: 1.51.0
grpc-spring-boot-starter: 2.14.0.RELEASE
protobuf: 3.21.9
spring-cloud-alibab: 2021.0.6.0
java: openjdk version "17.0.13" 64-Bit
nacos: 2.2.0
The text was updated successfully, but these errors were encountered:
The context
When a grpc service is started, the service is automatically registered in nacos and displayed in the nacos web console.
The question
I refer to the example, which uses spring-cloud-alibaba.
The
application.yml
is as follows:@EnableDiscoveryClient
should also be added.The service start well.
grpcurl --plaintext -d '{"name": "test"}' localhost:9787 com.example.grpc_nacos.idl.HelloService.SayHello
.But it is not registered in Nacos.
Stacktraces and logs
The service start well.
The application's environment
Which versions do you use?
How to reproduce
Just write a
HelloService
Demo.Additional Infomation
If I add
spring-boot-web-starter
in dependencies, the server fail to start.The error is most likely caused by
After the version is downgraded to the following, the service is registered and the gPRC port is displayed.
The text was updated successfully, but these errors were encountered: