6 Replies Latest reply on Jan 14, 2019 7:33 AM by Gerrit Hohl

    WildFly 14: Ignore POJO setter during JSON serialization / deserialization

    Gerrit Hohl Newbie

      Hi everyone,

       

      we have an application which was running on WildFly 10 / JEE7 so far. Now we ported it to WildFly 14 / JEE8 (and it seems we will move to WildFly 15 soon).

      In that application we have a POJO looking like this:

       

      @JsonInclude(Include.NON_NULL)
      public class StateInformation {
          private State state;
          private String stateMessage;
          
          public Information() {
              super();
          }
          
          public State getState() {
              return this.state;
          }
          
          public void setState(State state) {
              this.state = state;
          }
          
          public String getStateMessage() {
              return this.stateMessage;
          }
          
          public void setStateMessage(String stateMessage) {
              this.stateMessage = stateMessage;
          }
          
          public boolean setStateIfNotSet(State state, String stateMessage) {
              if (state == null)
                  throw new IllegalArgumentException("Argument state is null.");
              if (stateMessage == null)
                  throw new IllegalArgumentException("Argument stateMessage is null.");
              if (this.state == null) {
                  this.setState(state)
                  this.setStateMessage(stateMessage);
                  return true;
              }
              return false;
          }
      }

       

      Until now that class worked perfectly. But since we switched, we get an exception:

      RESTEASY008205: JSON Binding serialization error javax.json.bind.JsonbException: Invalid count of arguments for setter: public boolean org.example.rest.StateInformation.setStateIfNotSet(org.example.rest.State,java.lang.String): javax.ws.rs.ProcessingException: RESTEASY008205: JSON Binding serialization error javax.json.bind.JsonbException: Invalid count of arguments for setter: public boolean org.example.rest.StateInformation.setStateIfNotSet(org.example.rest.State,java.lang.String)

          at org.jboss.resteasy.plugins.providers.jsonb.JsonBindingProvider.writeTo(JsonBindingProvider.java:149)

      During the serialization / deseralization that method shouldn't be used at all. And before it wasn't also a problem, but now it is.

      I tried to annotate the method using:

      • com.fasterxml.jackson.annotation.JsonIgnore
      • javax.json.bind.annotation.JsonbTransient
      • javax.xml.bind.annotation.XmlTransient

      But none of them does the job (also no combination).

       

      Does anyone have any idea what has changed? And how we can fix it?