users@jersey.java.net

[Jersey] Re: Jersey Client question...

From: matrix <kochukavi_at_gmail.com>
Date: Wed, 21 Mar 2012 21:53:45 -0700 (PDT)

Hi,

Thanks for replying.

The error was as follows :
* com.sun.jersey.api.client.ClientHandlerException: A message body reader
for Java class generated.Cluster, and Java type class generated.Cluster,
and MIME media type text/html was not found*

The problem occurred because I tried to typecast the object recieved using
webresource.get() to the JAXB Annotated class

I found an alternate solution for this problem. It is as follows:

ByteArrayInputStream input = new ByteArrayInputStream(r.accept("

application/xml").get(String.class).getbytes());
JAXbContext jb = JAXBContext.newInstance(packageName);
Unmarshaller u = jb.createUnmarshaller();
MyJaxBGeneratedClass jaxBgen = (MyJaxBGeneratedClass) u.unmarshall(input);

It perfectly worked! :)

Thanks and Regards,
Kavitha Karunakaran



On Wed, Mar 21, 2012 at 3:45 PM, Pavel Bucek-2 [via Jersey] <
ml-node+s576304n7391824h93_at_n2.nabble.com> wrote:

> Hello,
>
> can you please include reported error?
>
> Thanks,
> Pavel
>
> On 3/21/12 10:13 AM, matrix wrote:
>
> > Hi,
> >
> > I am also running into the same problem. Even though the class I used
> for
> > webresource.get() method is created from an xsd using xjc, I am not able
> to
> > retrieve the value as the class itself. But the following works fine:
> >
> > *System.out.println(r.accept("application/xml").get(String.class)); *
> >
> > Actually prints the xml into output stream, when
> >
> > *MyJaxBGeneratedClass a =
> > r.accept("application/xml").get(MyJaxBGeneratedClass.class);*
> >
> > Throws up the error as pointed out by Kevin
> >
> > --
> > View this message in context:
> http://jersey.576304.n2.nabble.com/Jersey-Client-question-tp742181p7391707.html
> > Sent from the Jersey mailing list archive at Nabble.com.
> >
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://jersey.576304.n2.nabble.com/Jersey-Client-question-tp742181p7391824.html
> To unsubscribe from Jersey Client question..., click here<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=742181&code=a29jaHVrYXZpQGdtYWlsLmNvbXw3NDIxODF8Mzc5MzgzMDMw>
> .
> NAML<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>


--
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-Client-question-tp742181p7394374.html
Sent from the Jersey mailing list archive at Nabble.com.