Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resteasy with wildfly14: not all fields are returned

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

like image 762
Giamma Avatar asked Dec 07 '22 13:12

Giamma


1 Answers

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.

like image 192
Thai Ha Avatar answered Jan 30 '23 06:01

Thai Ha