users@jersey.java.net

[Jersey] Re: Jersey Client question...

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Thu, 22 Mar 2012 08:32:17 +0100

Hello,

problem here is that jersey applies built-in mechanism for
marshalling/unmarshalling only to relevant media types (and text/html is
not one of them).

try something like text/xml or application/xml.

Regards,
Pavel

On 3/22/12 5:53 AM, matrix wrote:
> 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] <[hidden
> email] </user/SendEmail.jtp?type=node&node=7394374&i=0>> 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.
> 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: Re: Jersey Client question...
> <http://jersey.576304.n2.nabble.com/Jersey-Client-question-tp742181p7394374.html>
> Sent from the Jersey mailing list archive
> <http://jersey.576304.n2.nabble.com/> at Nabble.com.