Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder Error?

Tags:

java

I am encountering the error: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder however i have imported the classes so am not sure why it is popping up. My build.gradle and code is below:

private String getAccessToken() {
    try {
        Log.e("tree","get access entered");
        javax.ws.rs.client.Client client = javax.ws.rs.client.ClientBuilder.newClient();
        javax.ws.rs.client.Entity<String> payload =
                javax.ws.rs.client.Entity.text("grant_type=client_credentials&redirect_uri=https://facebook.com/__");
        javax.ws.rs.core.Response response = client.target("https://v2.api.xapo.com/oauth2/token")
                .request(MediaType.TEXT_PLAIN_TYPE)
                .header("Authorization","Basic ___")
                .post(payload);
Log.e("tree","response completed");
            String body = response.readEntity(String.class);
            Log.e("tree","body "+body);
        } catch(Exception e) {
Log.e("tree","token exception "+e.getMessage());
        }
        return "";
    }
like image 421
Dreamers Org Avatar asked Mar 22 '16 23:03

Dreamers Org


2 Answers

You are missing the org.glassfish.jersey.core:jersey-client dependency.

like image 136
Shmulik Klein Avatar answered Sep 23 '22 01:09

Shmulik Klein


If you are using pom.xml, add the Maven dependency below in your pom.xml

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.2.Final</version>
</dependency>
like image 44
David Jesus Avatar answered Sep 22 '22 01:09

David Jesus