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.1
feature requires the Java EE 8 version of all dependent features. For example, thejaxrs-2.0
feature depends on theservlet-3.1
andjsonp-1.0
features. In JAX-RS 2.1, thejaxrs-2.1
feature depends on theservlet-4.0
andjsonp-1.1
features. Thejaxrs-2.1
feature also uses other Java EE 8 technologies, such asbean validation-2.0
andcdi-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.0
feature. - With the
jaxrs-2.0
andtransportSecurity-1.0
features enabled, the Liberty server automatically enables theappSecurity-2.0
feature, which is unnecessary for many user scenarios when you need only transport security. When you use thejaxrs-2.1
feature, Liberty does not automatically enableappSecurity
features when thetransportSecurity-1.0
feature is enabled. If you depend on both Secure Sockets Layer (SSL) and application security, explicitly add theappSecurity-3.0
feature in the server configuration. - In JAX-RS 2.0, the
CWWKW1001W
andCWWKW1002W
messages are normally logged when a lifecycle mismatch is detected, such as when a JAX-RS resource class is annotated with the@Singleton
annotation or the@ApplicationScoped
annotation, or when a JAX-RS provider class is annotated with the@RequestScoped
annotation. However, in JAX-RS 2.1, theCWWKW1001W
andCWWKW1002W
messages are logged to the trace file only when JAX-RS tracing is enabled.