I have this class but it is giving many errors I do not know what I do today that I try to solve. What do I do?
package manager.client;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
import model.Cliente;
public class MyClientGet {
public static void main(String[] args) {
//ClientConfig config = new ClientConfig();
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target("http://localhost:8080/Test");
WebTarget resourceWebTarget = webTarget.path("rest");
WebTarget pathdWebTarget = resourceWebTarget.path("cliente");
WebTarget pathdWebTargetQuery = pathdWebTarget.queryParam("id", 1);
Invocation.Builder invocationBuilder = pathdWebTargetQuery.request(MediaType.APPLICATION_JSON_TYPE);
Response response = invocationBuilder.get();
//System.out.println(response.getStatus());
Cliente user = response.readEntity(Cliente.class);
System.out.println("status: " + response.getStatus());
System.out.println("headers: " + response.getHeaders());
System.out.println(user.getId());
System.out.println(user.getUserName());
System.out.println(user.getPassword());
}
}
You are giving the following error:
Exception in thread "main" java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.collection.Values.lazy(Lorg/glassfish/jersey/internal/util/collection/Value;)Lorg/glassfish/jersey/internal/util/collection/LazyValue;
at org.glassfish.jersey.client.ClientConfig$State.<init>(ClientConfig.java:117)
at org.glassfish.jersey.client.ClientConfig.<init>(ClientConfig.java:452)
at org.glassfish.jersey.client.JerseyClientBuilder.<init>(JerseyClientBuilder.java:94)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:116)
at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:206)
at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:86)
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
at manager.client.MyClientGet.main(MyClientGet.java:21)