• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Rest Client  RSS feed

sreenivas vemula
Ranch Hand
Posts: 44
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am using Restful Webservices. Following is the code.

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;


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(HelloWorldRestClient.java:6)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.inject.Errors$Closure
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 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

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!