Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Rest Client

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.


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

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic