public class HelloWorldRestClient{
public static void main(String[] args) {
Client client = Client.create();
WebResource webResource = client
.resource("http://localhost:8080/TESTREST/services");
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.