Hi,
please see inline....
On 07/01/2011 12:39 AM, jimbeard_at_uoregon.edu wrote:
> Hello all,
>
> I am trying to use the Jersey client and am running into some issues.
> I have a simple class:
>
>
> public class Demo {
>
> public static void main(String [] args) {
>
> System.out.println("Line 1: "+args[0]);
>
> ClientConfig config = new DefaultClientConfig();
>
> Client client = Client.create(config);
>
> client.addFilter(new HTTPBasicAuthFilter("login", "password"));
> WebResource webResource = client.resource("http:// ");
are you sure about the above url? it appears something is missing there
> MultivaluedMap<String, String> queryParams = new
> MultivaluedMapImpl();
> queryParams.add("r25_username", args[0]);
> String s =
> webResource.queryParams(queryParams).delete(String.class);
> System.out.println("First output: " + s);
http delete usually just returns a status code, you might want
to retrieve ClientResponse instance rather than just String out of there.
> ClientResponse response =
> webResource.queryParams(queryParams).delete(ClientResponse.class,
> queryParams);
Above the queryParams are considered a request entity.
That is probably not what you wanted to do.
> System.out.println("Second output: " + response.toString());
> }
>
>
> }
>
> Which I am compiling against jersey-bundle-1.8.jar and
> jsr311-api-0.9.jar. It compiles fine but when I try to run it I get :
you should compile just against jersey-bundle-1.8.jar (do not see any
jax-rs stuff above,
the client api is jersey specific), and run with jersey-bundle-1.8.jar
and jsr311-api-1.1.1.jar
The 0.9 version of the jsr311-api jar is obsolete.
HTH,
~Jakub
>
> Exception in thread "main" java.lang.NoClassDefFoundError: Could not
> initialize class com.sun.jersey.core.header.MediaTypes
> at
> com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageB
> odyFactory.java:182)
> at
> com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageB
> odyFactory.java:176)
> at
> com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFact
> ory.java:162)
> at com.sun.jersey.api.client.Client.init(Client.java:342)
> at com.sun.jersey.api.client.Client.access$000(Client.java:118)
> at com.sun.jersey.api.client.Client$1.f(Client.java:191)
> at com.sun.jersey.api.client.Client$1.f(Client.java:187)
> at
> com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
> at com.sun.jersey.api.client.Client.<init>(Client.java:187)
> at com.sun.jersey.api.client.Client.<init>(Client.java:170)
> at com.sun.jersey.api.client.Client.create(Client.java:679)
> at Demo.main(Demo.java:20)
>
>
> Any idea what is going wrong here?
>
> Thanks!
>