{"id":5286,"date":"2014-03-30T20:21:21","date_gmt":"2014-03-30T20:21:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/issues-with-json-processing-using-jaxbelement-under-jersey-2-2-with-moxy-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:21:21","modified_gmt":"2014-03-30T20:21:21","slug":"issues-with-json-processing-using-jaxbelement-under-jersey-2-2-with-moxy-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/issues-with-json-processing-using-jaxbelement-under-jersey-2-2-with-moxy-collection-of-common-programming-errors\/","title":{"rendered":"Issues with JSON processing using JAXBElement under Jersey 2.2 with MOXy-Collection of common programming errors"},"content":{"rendered":"<p>I extended the <em>jersey-examples-moxy<\/em> code to use an XML schema definition instead of the JAXB annotated beans. The xjc compiled XML schema produces XML and JSON encodings identical to the original example.<\/p>\n<p>I followed the jersey instructions and used the <em>ObjectFactory<\/em> to generate the <em>JAXBElement Customer<\/em> object representation within CustomerResource.java. I also modified the client as described. I also incorporated the fix described in PUT issues with JSON processing using JAXB under Jersey 2.2 with MOXy<\/p>\n<p>The <strong>MediaType.APPLICATION_XML<\/strong> functions perfectly, and <strong>MediaType.APPLICATION_JSON<\/strong> works for GETs, but the client is failing to marshall JSON on a PUT with &#8220;MessageBodyWriter not found&#8221;. The following exception is thrown:<\/p>\n<pre><code>testJsonCustomer(org.glassfish.jersey.examples.jaxbmoxy.MoxyAppTest)  Time elapsed: 0.113 sec<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I extended the jersey-examples-moxy code to use an XML schema definition instead of the JAXB annotated beans. The xjc compiled XML schema produces XML and JSON encodings identical to the original example. I followed the jersey instructions and used the ObjectFactory to generate the JAXBElement Customer object representation within CustomerResource.java. I also modified the client [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5286","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5286"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5286\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}