Hi Marek,
Would you please explain to Ayaskant *how* to register the Jackson
feature? I know this is (sort of) in the documentation, but I couldn't
understand from the docs exactly what to do to make that happen. I'm
betting he's also possibly unclear about that as well (and I'd benefit from
seeing how this is supposed to be done even though we have muddled our way
though it, I am not confident enough in our solution to offer it as
something that should be done, we had a terrible time trying to understand
how to clearly put Jackson into play properly).
That would help, and thanks!
On Thu, Dec 19, 2013 at 3:34 AM, Marek Potociar
<marek.potociar_at_oracle.com>wrote:
> A very first few sentences from the linked documentation:
>
> Jersey* JSON support comes as a set of extension modules* *where* *each
> of these modules contains* an implementation of *a **Feature*<http://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/core/Feature.html>* that
> needs to be registered* *into your* Configurable<http://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/core/Configurable.html>instance
> (*client/server*). There are multiple frameworks that provide support for
> JSON processing and/or JSON-to-Java binding. The modules listed bellow
> provide support for JSON representations by integrating the individual JSON
> frameworks into Jersey. ...
>
> Further documentation section describe details how to enable JSON support
> with MOXy (8.1.2), JSON-P (8.1.3), Jackson (8.1.4) or Jettison (8.1.5). So,
> your problem is that you are not registering any of the features. Please
> select an extension module of your choice and follow the user guide to
> register the feature (as needed).
>
> HTH,
> Marek
>
>
> On 19 Dec 2013, at 08:20, ayaskant swain <ayas_swain_at_yahoo.com> wrote:
>
> Hi,
>
> I followed section 8.1.1.2 (JAXB based JSON support) in the User Guide
> document of JAX-RS API at this link -
> https://jersey.java.net/nonav/documentation/latest/user-guide.html#d0e4883
> .
>
> I have created a RESTful service using JAX-RS API 2.0 & deployed in my
> Tomcat 6.0.37. I want my service to return a Student object in JSON format
> to the REST client. The mapping of Student Java object (Annotated with
> @XmlRootElement) should automatically be taken care by the underlying JAXB
> API.
>
> But I am getting the below error on my server while trying to achieve
> this.
>
> org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:
> MessageBodyWriter not found for media type=application/json, type=class
> com.ayas.rest.model.jaxb.Student, genericType=class
> com.ayas.rest.model.jaxb.Student.
>
> I searched on google & found some suggestions to use a JACKSON library
> which will act as a provider for the JSON object. But nothing as such is
> written in the Jersey user guide link which I have posted above.
>
> There is no issue when I am using MediaType as APPLICATION_XML. It is
> perfectly working fine & returning XML string.
>
> I am attaching my source code of both Server & client. Please help.
>
> Thanks
> Ayaskant
> Bangalore
> <Student.java><StudentInfoClient.java><StudentInfoService.java><web.xml>
>
>
>