grpc-java/examples/example-servlet
Eric Anderson f3f4ed4ef3 Upgrade to Gradle 8.2.1 and upgrade plugins
Most changes are migrating from conventions to the equivalent
extensions. JMH, AppEngine, and Jib plugins trigger future compatibility
warnings with `--warning-mode all`.

The movement of configurations was to allow sourceSets to create the
configurations and then we just configure them. When configurations were
before sourceSets, we'd implicitly create the configuration.

The examples were _not_ updated to the newer Gradle, although the
non-Android examples work with the newer Gradle. The Android examples
use an older Android Gradle Plugin which will need to be upgraded first.
https://github.com/grpc/grpc-java/issues/10445
2023-08-02 13:29:44 -07:00
..
src/main servlet: Implement gRPC server as a Servlet (#8596) 2023-01-20 13:17:58 -08:00
README.md servlet: Implement gRPC server as a Servlet (#8596) 2023-01-20 13:17:58 -08:00
build.gradle Upgrade to Gradle 8.2.1 and upgrade plugins 2023-08-02 13:29:44 -07:00
settings.gradle servlet: Implement gRPC server as a Servlet (#8596) 2023-01-20 13:17:58 -08:00

README.md

Hello World Example using Servlets

This example uses Java Servlets instead of Netty for the gRPC server. This example requires grpc-java and protoc-gen-grpc-java to already be built. You are strongly encouraged to check out a git release tag, since these builds will already be available.

git checkout v<major>.<minor>.<patch>

Otherwise, you must follow COMPILING.

To build the example,

  1. Install gRPC Java library SNAPSHOT locally, including code generation plugin (Only need this step for non-released versions, e.g. master HEAD).

  2. In this directory, build the war file

$ ../gradlew war

To run this, deploy the war, now found in build/libs/example-servlet.war to your choice of servlet container. Note that this container must support the Servlet 4.0 spec, for this particular example must use javax.servlet packages instead of the more modern jakarta.servlet, though there is a grpc-servlet-jakarta artifact that can be used for Jakarta support. Be sure to enable http/2 support in the servlet container, or clients will not be able to connect.

To test that this is working properly, build the HelloWorldClient example and direct it to connect to your http/2 server. From the parent directory:

  1. Build the executables:
$ ../gradlew installDist
  1. Run the client app, specifying the name to say hello to and the server's address:
$ ./build/install/examples/bin/hello-world-client World localhost:8080