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; andgrizzly-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:
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)