Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JAX-RS implementations automatically support marshalling/unmarshalling of classes based on discoverable JAXB annotations, but because your payload is declared as <code>Object</code>, I think the created <code>JAXBContext</code> misses the <code>Department</code> class and when it's time to marshall it it doesn't know how.</p> <p>A quick and dirty fix would be to add a <a href="http://docs.oracle.com/javaee/6/api/javax/xml/bind/annotation/XmlSeeAlso.html" rel="noreferrer"><code>XmlSeeAlso</code></a> annotation to your response class:</p> <pre><code>@XmlRootElement @XmlSeeAlso({Department.class}) public class Response implements Serializable { .... </code></pre> <p>or something a little more complicated would be "to enrich" the JAXB context for the <code>Response</code> class by using a <code>ContextResolver</code>:</p> <pre><code>import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @Provider @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public class ResponseResolver implements ContextResolver&lt;JAXBContext&gt; { private JAXBContext ctx; public ResponseResolver() { try { this.ctx = JAXBContext.newInstance( Response.class, Department.class ); } catch (JAXBException ex) { throw new RuntimeException(ex); } } public JAXBContext getContext(Class&lt;?&gt; type) { return (type.equals(Response.class) ? ctx : null); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload