5

I'm migrating my application from wildfly 10 to wildfly 14 and I'm using resteasy 3.1.4 with jackson2. I have a strange behaviour with the response of some rest services: not all the fields are returned (and I'm sure they're extracted from mongodb). The only warning I see when deploying my application is: WFLYRS0018: Explicit usage of Jackson annotation in a JAX-RS deployment; the system will disable JSON-B processing for the current deployment. Consider setting the 'resteasy.preferJacksonOverJsonB' property to 'false' to restore JSON-B.

In the response I have two classes: public class Field implements Serializable {

   private static final long serialVersionUID = -230381150649916138L;

   private String name; // returned in response
   private FieldsTypeEnum type; // NOT returned in response
   private List<String> comboValues; // NOT returned in response
   private boolean required; // NOT returned in response

    //All getters and setters

}

public class ConfigurationField extends Field {

   private static final long serialVersionUID = -2727277793405725817L;

   private Integer row; // returned in response
   private boolean useForCalendar; // returned in response

   //All getters and setters

}

Any help or suggest or idea is really appreciated

Thanks

Giamma
  • 808
  • 2
  • 10
  • 21

3 Answers3

14

It has been 6 months since the question was asked. However, I faced the similar issue a few days ago on Wildfly 16.

The issue was caused by JsonBindingProvider takes precedence over the other providers for dealing with JSON payloads, particular the Jackson one. https://issues.jboss.org/browse/RESTEASY-1911

Please see documentation here. https://github.com/resteasy/Resteasy/commit/f6ddef5accb88d924e3d14ab15e081c79136fe55

It can be fixed by 2 ways without having to update your model (POJO) objects:

  • Adding system property when starting up Wildfly -Dresteasy.preferJacksonOverJsonB=true
  • Exclude jsonb module in jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <deployment>
        <exclusions>
            <module name="org.jboss.resteasy.resteasy-json-binding-provider" />
        </exclusions>
    </deployment>
</jboss-deployment-structure>

If you do not want to change Wildfly configuration, you have to update you models to conform with JsonB specification, e.g. public your private fields in your models, or adding suitable @Jsonb annotations to your fields, ... like here, https://www.baeldung.com/java-json-binding-api.

Thai Ha
  • 240
  • 6
  • 13
7

Based on the answer from Soner, this helped me when added to web.xml:

    <context-param>
        <param-name>resteasy.preferJacksonOverJsonB</param-name>
        <param-value>true</param-value>
    </context-param>

I prefer this solution in order to keep the configuration within the app code.

Jardo
  • 1,939
  • 2
  • 25
  • 45
2

I had similar problems within Wildfly 21. Adding a jboss-deployment-structure.xml like:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">
    <deployment>
        <exclusions>
            <module name="org.jboss.resteasy.resteasy-json-binding-provider"/>
        </exclusions>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

didn't help

For me the working solution was to add following line into the Wildfly standalone.conf to prefer jackson:

JAVA_OPTS="$JAVA_OPTS -Dresteasy.preferJacksonOverJsonB=true"
Soner
  • 213
  • 3
  • 9