Table of Contents
3.1 branch:
This user guide refers only to version 3.1.x of Jersey, its compatibility is described below.
Since version 3.1.0 all Jersey components are compiled with Java SE 11 target. It means, that you will need at least Java SE 11 to be able to compile and run your application which uses the latest Jersey 3.1.x. Some modules, however, are fully compatible with JDK 17 and above (Jetty modules based on Jetty 12 [since 3.1.4], Helidon Connector, Spring 6).
Please see Chapter 30, Migration Guide for additional compatibility information.
Table 2.1. Jersey 3.1.x JDK compatibility
Jersey version | JDK min version | JDK max version |
---|---|---|
3.1.0 | 11 | 19 |
3.1.1 | 11 | 19 |
3.1.2 | 11 | 21 |
3.1.3 | 11 | 21 |
3.1.4 | 11 | 22 |
3.1.5 | 11 | 22 |
3.1.6 | 11 | 23 |
3.1.7 | 11 | 23 |
With JDK 21 and above, Jersey (since 2.44) has the ability to use virtual threads instead of
the CachedThreadPool
in the internal ExecutorServices
.
Jersey also has the ability to specify the backing ThreadFactory
for the
default ExecutorServices
(the default ExecutorServices
can be overridden by the ExecutorServiceProvider SPI).
To enable virtual threads and/or specify the ThreadFactory
, use
CommonProperties.USE_VIRTUAL_THREADS and/or CommonProperties.THREAD_FACTORY
properties, respectively. See also the Section A.1, “Common (client/server) configuration properties” in appendix for property details.
Jersey is built, assembled and installed using Apache Maven. Non-snapshot Jersey releases are deployed to the Central Maven Repository. Jersey is also being deployed to Sonatype Maven repositories, which contain also Jersey SNAPSHOT versions. In case you would want to test the latest development builds check out the Sonatype Snapshots Maven repository.
An application that uses Jersey and depends on Jersey modules is in turn required to also include a set of 3rd party modules that Jersey modules depend on. Jersey is designed as a pluggable component architecture and different applications can therefore require different sets of Jersey modules. This also means that a set of external Jersey dependencies required to be included in the application dependencies may vary in each application based on the Jersey modules that are being used by the application.
Developers using Maven or a Maven-aware build system in their projects are likely to find it easier to include and manage dependencies of their applications compared to developers using ant or other build systems that are not compatible with Maven. This document will explain to both maven and non-maven developers how to depend on Jersey modules in their application. Ant developers are likely to find the Ant Tasks for Maven very useful.
If you are using Glassfish application server, you don't need to package anything with your application, everything is already included. You just need to declare (provided) dependency on JAX-RS API to be able to compile your application.
<dependency> <groupId>jakarta.ws.rs</groupId> <artifactId>jakarta.ws.rs-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency>
If you are using any Jersey specific feature, you will need to depend on Jersey directly.
<dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>3.1.9</version> <scope>provided</scope> </dependency> <!-- if you are using Jersey client specific features without the server side --> <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>3.1.9</version> <scope>provided</scope> </dependency>
Following dependencies apply to application server (servlet containers) without any integrated JAX-RS implementation. Then application needs to include JAX-RS API and Jersey implementation in deployed application.
<dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>3.1.9</version> </dependency> <!-- Required only when you are using JAX-RS Client --> <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>3.1.9</version> </dependency>
Applications running on plain JDK using only client part of JAX-RS specification need to depend only on client. There are various additional modules which can be added, like for example grizzly or apache or jetty connector (see dependencies snipped below). Jersey client runs by default with plain JDK (using HttpUrlConnection). See Chapter 5, Client API. for more details.
<dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>3.1.9</version> </dependency>
Currently available connectors:
<dependency> <groupId>org.glassfish.jersey.connectors</groupId> <artifactId>jersey-grizzly-connector</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.connectors</groupId> <artifactId>jersey-apache-connector</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.connectory</groupId> <artifactId>jersey-jetty11-connector</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.connectors</groupId> <artifactId>jersey-jetty-connector</artifactId> <version>3.1.9</version> </dependency>
Apart for a standard JAX-RS Servlet-based deployment that works with any Servlet container that supports Servlet 5 and higher, Jersey provides support for programmatic deployment to the following containers: Grizzly 3 (HTTP and Servlet), JDK Http server, Simple Http server and Jetty Http server (requires JDK 11+). This chapter presents only required maven dependencies, more information can be found in Chapter 4, Application Deployment and Runtime Environments.
<dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-grizzly2-http</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-grizzly2-servlet</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-jdk-http</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-simple-http</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-jetty-http</artifactId> <version>3.1.9</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-jetty-servlet</artifactId> <version>3.1.9</version> </dependency>
The following chapters provide an overview of all Jersey modules and their dependencies with links to the respective binaries (follow a link on a module name to get complete set of downloadable dependencies).
Table 2.2. Jersey Core
Jersey Core | |
---|---|
jersey-client | Jersey core client implementation |
jersey-common | Jersey core common packages |
jersey-server | Jersey core server implementation |
Table 2.3. Jersey Containers
Jersey Containers | |
---|---|
jersey-container-grizzly2-http | Grizzly 2 Http Container. |
jersey-container-grizzly2-servlet | Grizzly 2 Servlet Container. |
jersey-container-jdk-http | JDK Http Container |
jersey-container-jetty-http | Jetty Http Container (for JDK 17+) |
jersey-container-jetty-servlet | Jetty Servlet Container |
jersey-container-netty-http | Netty Http Container. |
jersey-container-servlet | Jersey core Servlet 3.x/5.x implementation |
jersey-container-servlet-core | Jersey core Servlet 2.x way implementation with Jakarta EE 9 adjustments |
jersey-container-simple-http | Simple Http Container |
jersey-gf-ejb | Jersey EJB for GlassFish integration |
Table 2.4. Jersey Connectors
Jersey Connectors | |
---|---|
jersey-apache5-connector | Jersey Client Transport via Apache 5 |
jersey-apache-connector | Jersey Client Transport via Apache |
jersey-grizzly-connector | Jersey Client Transport via Grizzly |
jersey-helidon-connector | Jersey Client Transport via Helidon |
jersey-jdk-connector | Jersey Client Transport via JDK connector |
jersey-jetty-connector | Jersey Client Transport via Jetty (for JDK 17+) |
jersey-jetty11-connector | Jersey Client Transport via Jetty 11.x |
jersey-netty-connector | Jersey Client Transport via Netty |
Table 2.5. Jersey Media
Jersey Media | |
---|---|
jersey-media-jaxb | JAX-RS features based upon JAX-B. |
jersey-media-json-binding | Jersey JSON-B support module. |
jersey-media-json-jackson | Jersey JSON Jackson (2.x) entity providers support module. |
jersey-media-json-jettison | Jersey JSON Jettison entity providers support module. |
jersey-media-json-processing | Jersey Jakarta JSON Processing entity providers support proxy module. |
jersey-media-kryo | Jersey/JAX-RS Message Body Writer and Reader using Kryo serialization framework |
jersey-media-moxy | Jersey JSON entity providers support module based on EclipseLink MOXy. |
jersey-media-multipart | Jersey Multipart entity providers support module. |
jersey-media-sse | Jersey Server Sent Events entity providers support module. |
Table 2.6. Jersey Extensions
Jersey Extensions | |
---|---|
jersey-bean-validation | Jersey extension module providing support for Bean Validation (JSR-349) API. |
jersey-cdi1x | Jersey CDI 1.1 integration |
jersey-cdi1x-ban-custom-hk2-binding | Jersey CDI integration - this module disables custom HK2 bindings |
jersey-cdi1x-servlet | Jersey CDI 1.x Servlet Support |
jersey-cdi1x-transaction | Jersey CDI 1.x Transactional Support |
jersey-cdi1x-validation | Jersey CDI 1.x Bean Validation Support |
jersey-declarative-linking | Jersey support for declarative hyperlinking. |
jersey-entity-filtering | Jersey extension module providing support for Entity Data Filtering. |
jersey-metainf-services | Jersey extension module enabling automatic registration of JAX-RS providers (MBW/MBR/EM) via META-INF/services mechanism. |
jersey-micrometer | Jersey extension module providing support for Micrometer. |
jersey-mp-config | Jersey extension module providing support for MicroProfile Configuration. |
jersey-mp-rest-client | Jersey extension module providing support for MicroProfile REST Client. |
jersey-mvc | Jersey extension module providing support for MVC. |
jersey-mvc-bean-validation | Jersey extension module providing support for Bean Validation in MVC. |
jersey-mvc-freemarker | Jersey extension module providing support for Freemarker templates. |
jersey-mvc-jsp | Jersey extension module providing support for JSP templates. |
jersey-mvc-mustache | Jersey extension module providing support for Mustache templates. |
jersey-mvc-thymeleaf | Jersey extension module providing support for Thymeleaf templates. |
jersey-proxy-client | Jersey extension module providing support for (proxy-based) high-level client API. |
jersey-rx-client-guava | Jersey Reactive Client - Guava (ListenableFuture) provider. |
jersey-rx-client-rxjava | Jersey Reactive Client - RxJava (Observable) provider. |
jersey-rx-client-rxjava2 | Jersey Reactive Client - RxJava2 (Flowable) provider. |
jersey-wadl-doclet | A doclet that generates a resourcedoc xml file: this file contains the javadoc documentation of resource classes, so that this can be used for extending generated wadl with useful documentation. |
jersey-weld2-se | WELD 2.x SE support |
Table 2.7. Jersey Test Framework
Jersey Test Framework | |
---|---|
container-runner-maven-plugin | The container runner maven plugin provides means to start and stop a container (currently Tomcat 10 and Glassfish 6 are supported). To deploy an application to this container or to repetitively redeploy and test an application in the container. |
custom-enforcer-rules | Jersey test framework Maven projects |
jersey-test-framework-core | Jersey Test Framework Core |
jersey-test-framework-provider-bundle | Jersey Test Framework Providers Bundle |
jersey-test-framework-provider-external | Jersey Test Framework - External container |
jersey-test-framework-provider-grizzly2 | Jersey Test Framework - Grizzly2 container |
jersey-test-framework-provider-inmemory | Jersey Test Framework - InMemory container |
jersey-test-framework-provider-jdk-http | Jersey Test Framework - JDK HTTP container |
jersey-test-framework-provider-jetty | Jersey Test Framework - Jetty HTTP container |
jersey-test-framework-provider-netty | Jersey Test Framework - Netty container |
jersey-test-framework-provider-simple | Jersey Test Framework - Simple HTTP container |
jersey-test-framework-util | Jersey Test Framework Utils |
memleak-test-common | Jersey test framework umbrella project |
Table 2.8. Jersey Test Framework Providers
Jersey Test Framework Providers | |
---|---|
jersey-test-framework-provider-bundle | Jersey Test Framework Providers Bundle |
jersey-test-framework-provider-external | Jersey Test Framework - External container |
jersey-test-framework-provider-grizzly2 | Jersey Test Framework - Grizzly2 container |
jersey-test-framework-provider-inmemory | Jersey Test Framework - InMemory container |
jersey-test-framework-provider-jdk-http | Jersey Test Framework - JDK HTTP container |
jersey-test-framework-provider-jetty | Jersey Test Framework - Jetty HTTP container (for JDK 11+) |
jersey-test-framework-provider-netty | Jersey Test Framework - Netty container |
jersey-test-framework-provider-simple | Jersey Test Framework - Simple HTTP container |
Table 2.9. Jersey Glassfish Bundles
Jersey Glassfish Bundles | |
---|---|
jersey-gf-ejb | Jersey EJB for GlassFish integration |
Table 2.10. Security
Security | |
---|---|
oauth1-client | Module that adds an OAuth 1 support to Jersey client. |
oauth1-server | Module that adds an OAuth 1 support to Jersey server |
oauth1-signature | OAuth1 signature module |
oauth2-client | Module that adds an OAuth 2 support to Jersey client |
Table 2.11. Jersey Examples
Jersey Examples | |
---|---|
assemblies | Jersey examples shared assembly types. |
bookstore-webapp | Jersey MVC Bookstore example. |
cdi-webapp | Jersey CDI example. |
clipboard | Jersey clipboard example. |
clipboard-programmatic | Jersey programmatic resource API clipboard example. |
declarative-linking | Declarative Hyperlinking - Jersey Sample |
entity-filtering | Jersey Entity Data Filtering Example. |
entity-filtering-security | Jersey Entity Data Filtering Security Example. |
entity-filtering-selectable | Jersey Entity Data Filtering Selectable Example. |
exception-mapping | Jersey example showing exception mappers in action. |
freemarker-webapp | Jersey Freemarker example. |
groovy | Groovy Jersey |
helloworld | Jersey annotated resource class "Hello world" example. |
helloworld-benchmark | Jersey "Hello World" benchmark example. |
helloworld-cdi2-se | Jersey "Hello world" example with CDI 2 SE. |
helloworld-netty | Jersey "Hello world" example on Netty container. |
helloworld-programmatic | Jersey programmatic resource API "Hello world" example. |
helloworld-pure-jax-rs | Example using only the standard JAX-RS API's and the lightweight HTTP server bundled in JDK. |
helloworld-webapp | Jersey annotated resource class "Hello world" example. |
helloworld-weld | Jersey annotated resource class "Hello world" example with Weld support. |
http-patch | Jersey example for implementing generic PATCH support via JAX-RS reader interceptor. Taken from Gerard Davison's blog entry: http://kingsfleet.blogspot.co.uk/2014/02/transparent-patch-support-in-jax-rs-20.html |
http-trace | Jersey HTTP TRACE support example. |
https-clientserver-grizzly | Jersey HTTPS Client/Server example on Grizzly. |
https-server-glassfish | Jersey HTTPS server on GlassFish example. |
java8-webapp | Java 8 Types WebApp Example. |
jaxb | Jersey JAXB example. |
jaxrs-types-injection | Jersey JAX-RS types injection example. |
jersey-ejb | Jersey Web Application (Servlet) examples parent POM. |
json-binding-webapp | Jersey JSON Binding example. |
json-jackson | Jersey JSON with Jackson example. |
json-jettison | Jersey JSON with Jettison JAXB example. |
json-moxy | Jersey JSON with MOXy example. |
json-processing-webapp | Jersey Jakarta JSON Processing example. |
json-with-padding | Jersey JSON with Padding example. |
managed-beans-webapp | Jersey Managed Beans Web Application Example. |
managed-client | Jersey managed client example. |
managed-client-simple-webapp | Jersey Web Application (Servlet) examples parent POM. |
managed-client-webapp | Jersey managed client web application example. |
multipart-webapp | Jersey Multipart example. |
open-tracing | Jersey OpenTracing example |
rx-client-webapp | Jersey Reactive Client WebApp Example. |
server-async | Jersey JAX-RS asynchronous server-side example. |
server-async-managed | Jersey JAX-RS asynchronous server-side example with custom Jersey executor providers. |
server-async-standalone | Standalone Jersey JAX-RS asynchronous server-side processing example. |
server-async-standalone-client | Standalone Jersey JAX-RS asynchronous server-side processing example client. |
server-async-standalone-webapp | Standalone Jersey JAX-RS asynchronous server-side processing example web application. |
server-sent-events-jaxrs | Jersey JAX-RS 2.1/3.0 Server-Sent Events example. |
server-sent-events-jersey | Jersey Server-Sent Events example. |
servlet3-webapp | Jersey Servlet 3 example with missing servlet-class in the web.xml file |
simple-console | Jersey Simple Console example |
sse-item-store-jaxrs-webapp | Jersey JAX-RS 2.1/3.0 SSE API-based item store example. |
sse-item-store-jersey-webapp | Jersey SSE API-based item store example. |
sse-twitter-aggregator | Jersey SSE Twitter Message Aggregator Example. |
system-properties-example | Jersey system properties example. |
webapp-example-parent | Jersey Web Application (Servlet) examples parent POM. |
xml-moxy | Jersey XML MOXy example. |