Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-20898

XML bind annotation used for JSON when both are set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 38.0.0.Beta1
    • 37.0.0.Final, 37.0.1.Final
    • REST
    • None
    • Hide

      Attaching a reproducer: jaxrstest.tar.gz

      1. Build and deploy the jaxrstestwar-1.0.0.war
      2. Go to /jaxrstest/
      3. Click on Included Object Mapper.
      4. Observer the result is using the XML annotations.
      5. For reference, click on and observe the Default Object Mapper.
      6. For previous behavior, deploy and observe on WF 36
      Show
      Attaching a reproducer: jaxrstest.tar.gz Build and deploy the jaxrstestwar-1.0.0.war Go to /jaxrstest/ Click on Included Object Mapper. Observer the result is using the XML annotations. For reference, click on and observe the Default Object Mapper. For previous behavior, deploy and observe on WF 36
    • ---
    • ---

      After upgrade to 37.0.0.Final (also present on 37.0.1.Final), when both XML bind annotations and Jackson annotations is set on a POJO returned by jax-rs with media-type "application/json", the resulting JSON returned is using the XML annotations.

      e.g.

       

      @JsonProperty("jsonElement")
      @XmlElement(name = "xml-element")
      private String testElement = "testValue"; 

      Will return {"xml-element": "testValue"}

       

      This behavior is different than WF 36 and prior.

       

      I believe the cause is that in WF 37, it ends up using an AnnotationIntrospectorPair [JakartaXmlBindAnnotationIntroSpector, JacksonAnnotationIntrospector],
      while in WF 36, it was just using a JacksonAnnotationIntrospector.

       

      This can be worked-around by registering a custom ContextResolver<ObjectMapper>, but I would like to know if this change is intended, and if the "legacy" behavior is supported?

      Alternatively, if the choice of priority for introspector/module could be made controllable?

       

              jperkins-rhn James Perkins
              gustav_brostrom Gustav Broström
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: