File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Problem with Rest Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem with Rest Client" Watch "Problem with Rest Client" New topic

Problem with Rest Client

sreenivas vemula
Ranch Hand

Joined: Jan 21, 2012
Posts: 44
Hi I am using Restful Webservices. Following is the code.


public class HelloWorldResource{
public String sayHello(@QueryParam("world") String world) {
return "Hello " + world;

Following is the REST client:

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;

public class HelloWorldRestClient{
public static void main(String[] args) {
Client client = Client.create();
WebResource webResource = client
String response = webResource.path("helloworld")
.queryParam("world", "World!").get(String.class);
System.out.println("Response: " + response);

When I try to the REST client I am getting the following errors:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/Errors$Closure
at HelloWorldRestClient.main(
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.inject.Errors$Closure
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
... 1 more

I executed the same program at my PC in home. Working well that time. Don't know what I did that time.

I have added all the required jar files and added the same in the classpath too. No compilation errors.

Please assist me.

Thanks in advance

I agree. Here's the link:
subject: Problem with Rest Client
It's not a secret anymore!