tag:blogger.com,1999:blog-1710464868724994296.post2763746568385891933..comments2023-06-29T09:48:09.653-04:00Comments on Java XML and JSON Binding: JAXB and JSON via Jettison - Namespace ExampleBlaise Doughanhttp://www.blogger.com/profile/02016807982653343777noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-1710464868724994296.post-1881460358352852692012-08-24T16:28:25.673-04:002012-08-24T16:28:25.673-04:00Hi Blaise,
I did these. The problem I'm seein...Hi Blaise,<br /><br />I did these. The problem I'm seeing is, <br /> - JBOSS AS tries to add the default jax providers(jackson, jettison) by default to any jax-rs code (https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments)<br /> - So, I followed the steps to exclude these and add a dependency to MOXy.<br /> - After executing, the server is not able to find any MessageBodyWriter/Reader for any resource and throwing "NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type"<br /> - If i include the default providers, this exception is gone.<br /><br />I know its more of a JBoss/RestEasy question and not related to MOXy, but hoping that you might have encountered anything like this before and can provide some solution :)<br /><br />I've posted this in jboss forum as well, lets see if I get any response form there.<br /><br />Thank you,<br />SoumikSoumikhttps://www.blogger.com/profile/07397319056379747454noreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-90121187487254006632012-08-23T16:15:25.922-04:002012-08-23T16:15:25.922-04:00Hi Soumik,
These instructions are second hand, bu...Hi Soumik,<br /><br />These instructions are second hand, but it is my understanding that you need to do the following:<br /><br />1) Create a module directory like <JBOSS_HOME>/modules/org/eclipse/persistence/main<br />2) Copy eclipselink.jar to this directory.<br />3) Add a module.xml under this directory that looks like:<br /><module xmlns="urn:jboss:module:1.1" name="org.eclipse.persistence"><br /> <resources><br /> <resource-root path="eclipselink.jar"/><br /> <!-- Insert resources here --><br /> </resources><br /> <dependencies><br /> <module name="javax.xml.bind.api"/><br /> </dependencies><br /></module><br />4) Leverage MOXyJsonProvider (see: <a href="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html" rel="nofollow">MOXy as Your JAX-RS JSON Provider - MOXyJsonProvider</a>)<br /><br />-BlaiseBlaise Doughanhttps://www.blogger.com/profile/02016807982653343777noreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-87108617039879616782012-08-21T13:08:19.206-04:002012-08-21T13:08:19.206-04:00Hi Blaise,
Thank you for your reply. I'm usin...Hi Blaise,<br /><br />Thank you for your reply. I'm using Jboss app server 7.1.<br /><br />-SoumikSoumikhttps://www.blogger.com/profile/07397319056379747454noreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-25245902552964063502012-08-21T10:57:47.675-04:002012-08-21T10:57:47.675-04:00Hi Soumik,
Using Jettison I am not sure how you p...Hi Soumik,<br /><br />Using Jettison I am not sure how you produce the JSON that you are looking for. Ever since JSON-binding was added to MOXy I stopped investigating Jettison.<br />- <a href="http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html" rel="nofollow">JSON Binding with EclipseLink MOXy - Twitter Example</a><br /><br />MOXy's <i>MOXyJsonProvider</i> will produce JSON like that by default, or if you are using the MOXy APIs directly you can set the <i>JAXBContextProperties.JSON_INCLUDE_ROOT</i> property to false.<br />- <a href="http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html" rel="nofollow">MOXy as Your JAX-RS JSON Provider - MOXyJsonProvider</a><br /><br />MOXy can be used with JBoss/RESTEasy but the configuration differs depending upon the version. Which version of JBoss are you using?<br /><br />-BlaiseBlaise Doughanhttps://www.blogger.com/profile/02016807982653343777noreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-74906548907332808672012-08-21T03:10:31.480-04:002012-08-21T03:10:31.480-04:00Is there any way to produce an json output like th...Is there any way to produce an json output like this from the above example using jettison mapped convention: {"@id":"123","prop.name":"Jane Doe"}<br /><br />Basically, I don't want the json output to be wrapped inside the xmlroot element (which jettison usually does).<br /><br />Also, on a different note, I've learnt a lot from the useful examples in your blog. Will you be able to show us some example to configure MOXy with jboss resteasy server, so that we can use it as a jaxb provider instead of the default jettison.<br /><br />Thank you so much.<br /><br />--SoumikSoumikhttps://www.blogger.com/profile/07397319056379747454noreply@blogger.comtag:blogger.com,1999:blog-1710464868724994296.post-46924545836666210302011-09-14T14:47:13.347-04:002011-09-14T14:47:13.347-04:00Thanks for this post!!Thanks for this post!!Anonymousnoreply@blogger.com