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.
jaxrs-2.1feature requires the Java EE 8 version of all dependent features. For example, the
jaxrs-2.0feature depends on the
jsonp-1.0features. In JAX-RS 2.1, the
jaxrs-2.1feature depends on the
jaxrs-2.1feature also uses other Java EE 8 technologies, such as
cdi-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
@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
- With the
transportSecurity-1.0features enabled, the Liberty server automatically enables the
appSecurity-2.0feature, which is unnecessary for many user scenarios when you need only transport security. When you use the
jaxrs-2.1feature, Liberty does not automatically enable
appSecurityfeatures when the
transportSecurity-1.0feature is enabled. If you depend on both Secure Sockets Layer (SSL) and application security, explicitly add the
appSecurity-3.0feature in the server configuration.
- In JAX-RS 2.0, the
CWWKW1002Wmessages 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, the
CWWKW1002Wmessages are logged to the trace file only when JAX-RS tracing is enabled.