SystemTests with Apache CXF, JAX-RS, JSON-P on Java 11

To use Apache CXF JAX-RS 2.X client with JSON-P on Java 11 you will have to include the following dependencies first:

<!-- Java 11 comes without the "enterprise" dependencies -->
<!-- cxf / JAX-RS client dependencies dependencies -->        
<!-- JSON-P -->             

The Java release version has to be set to 11 and the maven compiler to the most recent version:


You will have to register the JsrJsonpProvider to get automatic serialization into JSON-P objects:

public class HealthCheckIT {

    private Client client;
    private WebTarget tut;

    public void init() {
        this.client = ClientBuilder.newClient().register(JsrJsonpProvider.class);
        this.tut ="http://localhost:9080/health");

    public void health() {
        Response response = this.tut.request().get();
        assertThat(response.getStatus(), is(200));
        JsonObject health = response.readEntity(JsonObject.class);
        JsonArray checks = health.getJsonArray("checks");
See you at Web, MicroProfile and Java EE Workshops at MUC Airport, particularly at the Java EE CI/CD, Testing and Quality workshop


Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments