0

When we upgraded RestEasy to 6.0.1 on Payara 5, we noticed that Payara now uses Yasson to serialize and deserialize objects, resulting in all @JsonIgnore, @JsonProperty to be ignored. We have added the jersey.config.jsonFeature context-param as specified in the docs:

<context-param>
    <param-name>jersey.config.jsonFeature</param-name>
    <param-value>JacksonFeature</param-value>
</context-param>

Falling back to RestEasy to 3, 4 or 5, Payara 5 again starts using Jackson and all @Json annotations are honored again.

How does RestEasy decide the provider (Yasson vs Jackson) and how can one force Jackson in RestEasy 6.0.1 on Payara?

chrisl08
  • 1,658
  • 1
  • 15
  • 24
  • Are you using RESTEasy or Jersey? I believe Payara uses Jersey and the property you are setting is for Jersey not RESTEasy. – James R. Perkins Aug 15 '22 at 14:41
  • @JamesR.Perkins I am trying to use Rest Easy, which seems to work on Payara prior to RestEasy 6 – chrisl08 Aug 15 '22 at 16:24
  • I don't know much about Payara, but the only differences in RESTEasy 5.x and 6.x is the Jakarta namespace change. It should behave the same. That said you could try the `resteasy.preferJacksonOverJsonB` context parameter. – James R. Perkins Aug 15 '22 at 20:02

1 Answers1

0

After spending a couple of days investigating this, the solution was to:

  1. Add jersey-media-json-jackson dependency to the POM:
  <dependency>
      <groupId>org.glassfish.jersey.media</groupId>
      <artifactId>jersey-media-json-jackson</artifactId>
      <version>2.26</version>
  </dependency>
  1. Register org.glassfish.jersey.jackson.JacksonFeature.class in your Application class like so:

    @ApplicationPath("services")
     public class ApplicationConfig extends Application {
    
     @Override
     public Set<Class<?>> getClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(org.glassfish.jersey.jackson.JacksonFeature.class);
         // add the rest of your classes here
         return classes;
     }   
     }
    
chrisl08
  • 1,658
  • 1
  • 15
  • 24