java.lang.ClassNotFoundException:org.glassfish.jersey.client.JerseyClientBuilder错误?

时间:2016-03-22 23:20:37

标签: java

我遇到错误:java.lang.ClassNotFoundException:org.glassfish.jersey.client.JerseyClientBuilder但是我已经导入了类,所以我不确定它为什么会弹出。我的build.gradle和代码如下:

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 "";
    }

2 个答案:

答案 0 :(得分:16)

您缺少org.glassfish.jersey.core:jersey-client依赖项。

答案 1 :(得分:1)

如果您使用的是pom.xml,请在下面的pom.xml中添加Maven依赖项

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.2.Final</version>
</dependency>