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, the jaxrs-2.0 feature depends on the servlet-3.1 and jsonp-1.0 features. In JAX-RS 2.1, the jaxrs-2.1 feature depends on the servlet-4.0 and jsonp-1.1 features. The jaxrs-2.1 feature also uses other Java EE 8 technologies, such as bean validation-2.0 and 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 @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 and transportSecurity-1.0 features enabled, the Liberty server automatically enables the appSecurity-2.0 feature, which is unnecessary for many user scenarios when you need only transport security. When you use the jaxrs-2.1 feature, Liberty does not automatically enable appSecurity features when the transportSecurity-1.0 feature is enabled. If you depend on both Secure Sockets Layer (SSL) and application security, explicitly add the appSecurity-3.0 feature in the server configuration.
  • In JAX-RS 2.0, the CWWKW1001W and CWWKW1002W 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, the CWWKW1001W and CWWKW1002W messages are logged to the trace file only when JAX-RS tracing is enabled.