It seems to me that it is possible to run gRPC server on Servlet Server sharing the same port, say 8080 (see Servlet Server section of Spring gRPC doc
https://docs.spring.io/spring-grpc/reference/server.html). Below is part of my pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.4</version>
<relativePath /> <!--lookup parent from repository -->
</parent>
<properties>
<java.version>17</java.version>
<grpc.version>1.70.0</grpc.version>
<protobuf-java.version>3.25.6</protobuf-java.version>
<spring-grpc.version>0.7.0</spring-grpc.version>
</properties>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
</dependency>
... ... ...
Following is the console log when the app starts
toConfiguration$GrpcServletConfiguration : Registering gRPC service: StatusQuery
toConfiguration$GrpcServletConfiguration : Registering gRPC service: grpc.reflection.v1.ServerReflection
toConfiguration$GrpcServletConfiguration : Registering gRPC service: grpc.health.v1.Health
... ... ...
o.s.b.d.a.OptionalLiveReloadServer
: LiveReload server is running on port 35729
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/web-context'
: Started QueryServiceApplication in 23.59 seconds (process running for 25.383)
o.a.c.c.C.[.[.[/web-context]
: Initializing Spring DispatcherServlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms
Then try to call grpc service by using grpcurl but get error
grpcurl -d "{\"name\":\"USA\"}" -plaintext localhost:8080 HelloWorld.SayHello
Error invoking method "HelloWorld.SayHello": failed to query for service descriptor "HelloWorld": server does not support the reflection API
grpcurl -d "{\"name\":\"USA\"}" -plaintext localhost:8080 HelloWorld/SayHello
Error invoking method "HelloWorld/SayHello": failed to query for service descriptor "HelloWorld": server does not support the reflection API
grpcurl -d "{\"name\":\"USA\"}" -plaintext localhost:8080 web-context/HelloWorld/SayHello
Error invoking method "web-context/HelloWorld/SayHello": failed to query for service descriptor "web-context/HelloWorld": server does not support the reflection API
Does anyone have some idea?