@XmlTransient not working for JAX-RS JSON responses in RESTEasy

Solution Unverified - Updated -

Issue

  • I am using JBoss EAP 6.3 straight out of the box. In other words, I have not tweaked or modified it except for adding datasources.
  • I have a POJO class with some fields annotated with @XmlTransient. This annotation is being ignored.
  • This problem happens only when a JAX-RS method is annotated with @Produces("application/json"); it does not happen for a method with @Produces("application/xml"), i.e. @XmlTransient just work as expected for XML responses.
  • For instance, with the following POJO class:
    private String ignored;
    @XmlTransient
    public String getIgnored() { return ignored; }
  • For "application/xml" I get:
<return>
  <message>
    <content>Goodbye, RESTEasy!</content>
  </message>
</return>
  • But for "application/json" I get:
{
  "message" : {
    "content" : "Hello, RESTEasy!",
    "ignored" : "Ignore me!!!"
  }
}

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content