Google云端硬盘文件:com.google.api.client.http.HttpHeaders.getAuthenticateAsList

时间:2014-06-07 17:20:47

标签: java google-app-engine google-drive-api

到目前为止,我们已经实施了一个没有问题的批处理过程。

从今天下午开始,它已经开始发出错误并且流程结束,留下处理数千个文件。

正如我们可以检查的那样,进程不会跳转到同一个文件,而是完全随机的。它可能是在处理文件200th,1000th,450000th ...

这是给我们的错误:

java.lang.NoSuchMethodError: com.google.api.client.http.HttpHeaders.getAuthenticateAsList()Ljava/util/List;
at com.google.api.client.auth.oauth2.Credential.handleResponse(Credential.java:245)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:992)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.EjecucionExpress.EjecutaExpress.obtenTamanios(EjecutaExpress.java:588)
at com.EjecucionExpress.EjecutaExpress.obtenTamaniosRaid(EjecutaExpress.java:701)
at com.EjecucionExpress.EjecutaExpress.doGet(EjecutaExpress.java:159)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

..............

在" EjecutaExpress"的第588行;课程,在" obtenTamanios"方法,我们有代码:

File file = service.files().get(fileID).execute();

这是我们为Google云端硬盘获取服务所需的代码实现。

public static final List<String> SCOPES = Arrays.asList(
            "https://www.googleapis.com/auth/drive",
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/userinfo.profile");

            -----------------------------------------------------------

            HttpTransport httpTransport = new NetHttpTransport();
            JacksonFactory jsonFactory = new JacksonFactory();

            GoogleCredential credential = new GoogleCredential.Builder()
                    .setTransport(httpTransport)
                    .setJsonFactory(jsonFactory)
                    .setServiceAccountUser(emailID)
                    .setServiceAccountId(
                            "CLIENT-ID-XXXXXXXXXXXXXX")
                    .setServiceAccountScopes(SCOPES)
                    .setServiceAccountPrivateKeyFromP12File(
                            new java.io.File(
                                    "P12-FILE"))
                    .build();
            credential.refreshToken();

            Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
                    .setHttpRequestInitializer(credential)
                    .setApplicationName("New Drive Service").build();

有人知道为什么会这样吗?

由于

1 个答案:

答案 0 :(得分:1)

Drive API正在尝试调用this function,该版本仅在1.16版本之后才可用。

您使用的是哪个版本的google-http-java-client?我们遇到了类似的问题,通过从1.15更新到1.18来解决。