Grizzly HTTP Server

Last update: 2025-03-06 16:08:24 +0800 +0800
tags: Java | Grizzly | Http | Jax-Rs
Available translations: 日本語 / 中文(简体) / 中文(繁體)

Grizzly is a Java NIO networking framework maintained by the Eclipse EE4J project. Its grizzly-framework module builds on Java’s non-blocking I/O APIs; it is not a direct wrapper around a particular operating-system API such as epoll.

Modules #

Common Grizzly modules include:

  • grizzly-http, which provides HTTP protocol support;
  • grizzly-http-server, an embeddable HTTP server with Grizzly’s own API; and
  • grizzly-http-servlet, which provides servlet-related integration.

Grizzly is used by GlassFish and can also run small embedded services. It is an HTTP server, not a Jakarta REST implementation. Combine it with Jersey when serving JAX-RS resources.

Run Jersey on Grizzly #

Create a Jersey ResourceConfig, register resource classes or packages, then create and start the server:

java
ResourceConfig config = new ResourceConfig()
        .packages("com.example.api");

HttpServer server = GrizzlyHttpServerFactory.createHttpServer(
        URI.create("http://0.0.0.0:8080/"), config, false);
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow));

Use compatible Jersey and Grizzly versions managed by the Jersey BOM or platform. Bind deliberately: 0.0.0.0 exposes the service on all interfaces, whereas 127.0.0.1 limits it to the local machine. Configure TLS, request limits, timeouts, graceful shutdown, and structured logging before using an embedded server in production.

Comments

Read or comment on GitHub (sign-in required to comment)