JAX-RS 2.1 behavior changes
Liberty supports the Java™ API for RESTful Web Services Version 2.1 (JAX-RS 2.1). Before you use JAX-RS 2.1 in Liberty, you can learn about the differences between JAX-RS 2.0 and JAX-RS 2.1.
- JAX-RS 2.1 adds new APIs, such as Server-Sent Events (SSE) and Reactive Client. For more information on these APIs and other changes, see the JAX-RS 2.1 specification and JavaDoc.
- The
jaxrs-2.1feature requires the Java EE 8 version of all dependent features. For example, thejaxrs-2.0feature depends on theservlet-3.1andjsonp-1.0features. In JAX-RS 2.1, thejaxrs-2.1feature depends on theservlet-4.0andjsonp-1.1features. Thejaxrs-2.1feature also uses other Java EE 8 technologies, such asbean validation-2.0andcdi-2.0, when they are enabled. - JAX-RS 2.1 uses JSON-B to serialize and deserialize JSON to objects, but JAX-RS 2.0 uses
Jackson. Subtle differences might exist in serialization and deserialization and might produce a
different JSON output. Options are included with these differences. For example, you can customize
the JSON-to-object transformation by using the various JSON-B APIs, such as
@JsonProperty,@JsonbIgnore, and more. Alternatively, instead of using JSON-B with JAX-RS 2.1, you can package Jackson with the application and use the Jackson JAX-RS provider.To use JSON-B APIs, enable the
jsonb-1.0feature. - With the
jaxrs-2.0andtransportSecurity-1.0features enabled, the Liberty server automatically enables theappSecurity-2.0feature, which is unnecessary for many user scenarios when you need only transport security. When you use thejaxrs-2.1feature, Liberty does not automatically enableappSecurityfeatures when thetransportSecurity-1.0feature is enabled. If you depend on both Secure Sockets Layer (SSL) and application security, explicitly add theappSecurity-3.0feature in the server configuration. - In JAX-RS 2.0, the
CWWKW1001WandCWWKW1002Wmessages are normally logged when a lifecycle mismatch is detected, such as when a JAX-RS resource class is annotated with the@Singletonannotation or the@ApplicationScopedannotation, or when a JAX-RS provider class is annotated with the@RequestScopedannotation. However, in JAX-RS 2.1, theCWWKW1001WandCWWKW1002Wmessages are logged to the trace file only when JAX-RS tracing is enabled.