users@jersey.java.net

Re: [Jersey] java.lang.IllegalArgumentException: Error parsing media type

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 17 Jun 2009 12:09:03 +0200

Hi Michael,

The media type "text/plain;javascript" is not a valid media type as
defined by the HTTP 1.1 specification [1].

Parameters require a value. Note that content negotiation will only
take into account the type and subtype of the media type and not any
parameters.


On Jun 17, 2009, at 2:11 AM, Michael Andrews wrote:

> Hi,
>
> I am trying to associate the MIME type "test/plain;javascript" with
> a JSON Provider. From the many examples I have gleaned from the
> mailing list and docs, I tried this:
>
> ClientConfig config = new DefaultClientConfig();
> config.getClasses().add(JSONRootElementProvider.class);
> Client client = Client.create(config);


You do not need to explicitly add JSONRootElementProvider, it is
implicitly included if you include the Jersey JSON jar in the class
path. So in this case you can just do:

   Client client = Client.create();

Also you are not really dealing with "javascript" it is "json" which
is different, the latter is a data format that is a subset of the
javascript language and needs to be processed different from
javascript itself for security reasons.

Thus you should use "application/json" if you can do so.

Paul.

[1] http://greenbytes.de/tech/webdav/rfc2616.html#media.types
      http://greenbytes.de/tech/webdav/rfc2616.html#transfer.codings

>

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>