users@jersey.java.net

Re: [Jersey] Having problems with provider after upgrading from 0.6 to 1.0.3 jersey

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 10 Jul 2009 10:20:24 +0200

On Jul 9, 2009, at 6:00 PM, vaidya nathan wrote:

> Thanx Paul,
>
> Is this something that has changed from 0.6 to 1.0.3.

Yes, in versions previous to 1.0.2 (IIRC) the consuming of JAXB types
was open to any media type, which was an error as specified by JAX-RS,
which restricts the media types to those of XML media types, "text/
xml", "application/xml" and "application/*+xml".


> After i made changes to my client proxy
>
> conn.setRequestProperty("Content-Type", "application/xml");
>
> it started working.
>
> Also i did verify that it recognizes my provider in the tomcat
> logs.So thanx for that
>

Great.

Paul.

> Cheers
> Vaidya
>
>
>
> On Thu, Jul 9, 2009 at 10:09 AM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
>
> On Jul 9, 2009, at 5:00 PM, vaidya nathan wrote:
>
> This is my resource
>
> @POST
> @Path("contractinfo/search")
> @Produces("application/xml")
> public Response findMethod(Criterea)
>
> where Criterea is a user defined object duly jaxb annotated. I have
> a JAXBElementProvider as follows
>
> @Provider
> @Produces("application/xml")
> @Consumes("application/xml")
> public class JAXBElementProvider<T> implements MessageBodyReader<T>,
> MessageBodyWriter<T>{
>
> with the readFrom and writeTo properly coded (it works for 0.6 ).
> The problem i am having is as follows
>
> 1. i upgraded from 0.6 to 1.0.3 (changed lot of stuff like
> annotations,class locations,etc)
> 2. i am able to make a request to another uri
> @GET
> @Produces("text/plain")
> @Path("ping")
> public String ping() {
> return "pong";
> }
>
>
> The client that i use is a client proxy which uses the
> uribuilder(still the old way ) and with ping it goes and gets the
> pong response, but when i send a request which sends the xml (with
> criterea) i get the following error in the tomcat server logs
> SEVERE: A message body reader for Java type, class <Class> , and
> MIME media type, application/x-www-form-urlencoded, was not found
>
>
> It looks like you client is sending a content-type of "application/x-
> www-form-urlencoded" instead of "application/xml" for the POST
> request. You need to set the content-type to "application/xml".
>
>
>
>
> I added the mimepull as someone suggested but to no avail. I dont
> think that it is using my provider. is there a way in which i need
> to register the provider which has changed between 0.6 and 1.0.3 ?
>
>
> In you Tomcat server logs you should see some output stating that it
> found the provider class JAXBElementProvider ? correct ?
>
> Paul.
>
>
> How do i make the resource accept xmls ?
>
> Please help
>
> Cheers
> Restuser
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>