Thorntail 2.7 has reached end of life and it is recommended you migrate to Quarkus or WildFly. This however might not be possible for your organization. You could have many applications using an older version of Thorntail and the effort to migrate to Quarkus could be expensive.
In such a case, you could upgrade the 3PPs and security aspects by upgrading to Thorntail 2.7 instead.
We will cover one of the breaking changes that occurred when upgrading Thorntail 2.5 to Thorntail 2.7 and that is the introduction of JSON-B JsonBindingProvider which is prioritized over the previous JSON-P Provider.
The JAX-RS 2.1 specification states that JSON-B shall take precedence over any over providers.
11.2.6 Java API for JSON Processing
In a product that supports the Java API for JSON Processing (JSON-P) [18], implementations MUST support entity providers for JsonValue and all of its sub-types: JsonStructure, JsonObject, JsonArray, JsonString and JsonNumber.
Note that other types from the JSON-P API such as JsonParser, JsonGenerator, JsonReader and JsonWriter can also be integrated into JAX-RS applications using the entity providers for InputStream and StreamingOutput.
11.2.7 Java API for JSON Binding
In a product that supports the Java API for JSON Binding (JSON-B) [19], implementations MUST support entity providers for all Java types supported by JSON-B in combination with the following media types: application/json, text/json as well as any other media types matching */json or */*+json.Note that if JSON-B and JSON-P are both supported in the same environment, entity providers for JSON-B take precedence over those for JSON-P for all types except JsonValue and its sub-types.
Now that is great, however JSON-B ignores all private fields and that means all entities with private fields will need to be changed to either public fields or adding getters/setters. If you have a great amount of such entities, it is a lot of work to modify.
An exception below is one you would encounter if JSON-B provider is the currently used provider in your RestClient and it is attempting to de-serialize an entity. Eclipse Yasson is used to de-serialize, and Yasson is an official reference implementation of JSON Binding (JSON-B) (JSR-367).
javax.ws.rs.ProcessingException: RESTEASY008200: JSON Binding deserialization error: javax.json.bind.JsonbException: Can't create instance
Caused by: java.lang.IllegalAccessException: class org.eclipse.yasson.internal.ReflectionUtils cannot access a member of class com.example.model.YourEntity with modifiers "private"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
If you were using Praya which is another Microprofile/Jakarta EE compatible server, you could solve this issue by creating a ContextResolver/PropertyVisiblityStrategy. This however will not work on Thorntail/Wildfly.
https://github.com/OpenLiberty/open-liberty/issues/5903
Adding the <artifactId>microprofile</artifactId> fraction is what is causing the problem because it has jaxrs-jsonb as a transitive dependency. However excluding this dependency still does not fix the problem!!
It is best to include only the dependencies you need and this should allow our existing entities with private fields to work and your application working again.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom-all</artifactId>
<version>${version.thorntail}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Dont include microprofile fraction, but rather choose the fractions you need -->
<!-- =========================== -->
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>jaxrs-jsonp</artifactId>
</dependency>
<!-- =========================== -->
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>microprofile-config</artifactId>
</dependency>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>microprofile-restclient</artifactId>
</dependency>
Now, on application startup you should see the follow installed fractions:
.
.
.
.
2021-10-03 12:49:56,154 INFO [org.wildfly.swarm] (main) THORN0013: Installed fraction: JAX-RS - STABLE io.t
horntail:jaxrs:2.7.0.Final
2021-10-03 12:49:56,154 INFO [org.wildfly.swarm] (main) THORN0013: Installed fraction: MicroProfile Rest Client - STABLE io.t
horntail:microprofile-restclient:2.7.0.Final
2021-10-03 12:49:56,156 INFO [org.wildfly.swarm] (main) THORN0013: Installed fraction: JAX-RS with JSON-P - STABLE io.t
horntail:jaxrs-jsonp:2.7.0.Final
.
.
.
.
THORN99999: Thorntail is Ready