0

I'm working on making a REST call from Jersey, using docs from blogs.oracle.com. Here's my import statement to get access to WebResource:

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

I'm getting the error, "Cannot resolve symbol 'Client'". How can I correct this?

UPDATE with requested info:

Here's the complete code required to reproduce the anomaly on my installation:

package com.nc4.cdn.jcdn.jersey.resource;
import com.sun.jersey.api.*;
import com.sun.jersey.api.client.WebResource; //<==error on this line -- "Cannot resolve symbol 'Client'"

Per request, here is a list of all files in my library folder:

apache-maven-2.0.9.jar
asm-3.1.jar
classworlds-1.1.jar
commons-cli-1.0.jar
commons-httpclient-2.0.2.jar
commons-logging-1.0.4.jar
doxia-sink-api-1.0-alpha-10.jar
jdom-1.0.jar
jersey-core-1.0.jar
jersey-server-1.0.jar
jettison-1.3.8.jar
META-INF
jettison
jsch-0.1.27.jar
jsr311-api-1.0.jar
jtidy-4aug2000r7-dev.jar
junit-3.8.1.jar
maven-artifact-2.0.9.jar
maven-artifact-manager-2.0.9.jar
maven-core-2.0.9.jar
maven-error-diagnostics-2.0.9.jar
maven-model-2.0.9.jar
maven-monitor-2.0.9.jar
maven-plugin-api-2.0.jar
maven-plugin-descriptor-2.0.9.jar
maven-plugin-parameter-documenter-2.0.9.jar
maven-plugin-registry-2.0.9.jar
maven-profile-2.0.9.jar
maven-project-2.0.9.jar
maven-reporting-api-2.0.9.jar
maven-repository-metadata-2.0.9.jar
maven-settings-2.0.9.jar
maven-toolchain-2.0.9.jar
maven-wadl-plugin-1.0.jar
maven-wadl-plugin-1.0-sources.jar
plexus-container-default-1.0-alpha-9-stable-1.jar
plexus-interactivity-api-1.0-alpha-4.jar
plexus-utils-1.5.1.jar
slide-webdavlib-2.1.jar
stax-api-1.0.1.jar
xml
META-INF
wagon-file-1.0-beta-2.jar
wagon-http-lightweight-1.0-beta-2.jar
wagon-http-shared-1.0-beta-2.jar
wagon-provider-api-1.0-beta-2.jar
wagon-ssh-1.0-beta-2.jar
wagon-ssh-common-1.0-beta-2.jar
wagon-ssh-external-1.0-beta-2.jar
wagon-webdav-1.0-beta-2.jar
xercesImpl-2.6.1.jar
xml-apis-1.0.b2.jar
xml-im-exporter-1.1.jar
VikR
  • 4,818
  • 8
  • 51
  • 96
  • suppose you import the correct `jersey-client` for the project. refer this [post](http://www.mkyong.com/webservices/jax-rs/restful-java-client-with-jersey-client/) – Rajith Pemabandu May 04 '17 at 00:51
  • Please specify the correct import statement, @RajithPemabandu. As noted in my subject line, I'm a Java newbie! – VikR May 04 '17 at 01:53
  • @RajithPemabandu, are you referring to `import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource;` as in that post? I get the same error using those statements. – VikR May 04 '17 at 01:59

2 Answers2

1

You need to import the Client class also:

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

(Most IDEs can automatically organise your imports for you)

You also need jersey-client-1.0.jar in your classpath

Catchwa
  • 5,845
  • 4
  • 31
  • 57
  • With the following import lines, I still get the "Cannot resolve symbol 'Client'" error: `import org.glassfish.jersey.client.*; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; ` – VikR May 04 '17 at 01:34
  • @VikR there's not enough information in your question to help anymore. You need to post the smallest amount of code that reproduces you issue, and give more information on what libraries you have on your classpath. – Catchwa May 04 '17 at 01:40
  • I've added more info to the original post. Please let me know if I can add more info. – VikR May 04 '17 at 01:53
  • @ Catchwa what's the correct `import` statement to use in order to access `jersey-client-1.0`? – VikR May 04 '17 at 06:33
  • @VikR you already have it. You just need the JAR file in your libraries. – Catchwa May 04 '17 at 09:46
0

Changing the import statement to:

import org.glassfish.jersey.client.*;

...fixed it.

VikR
  • 4,818
  • 8
  • 51
  • 96