google API Bigquery null pointer java



我尝试设置带有Java API的BigQuery项目以访问它。但是,当我运行Google BigQueryInstalledauthdemo类时,我会收到此错误:

java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at com.google.api.client.json.jackson.JacksonFactory.createJsonParser(JacksonFactory.java:70)
at com.google.api.client.json.JsonFactory.fromInputStream(JsonFactory.java:223)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(GoogleClientSecrets.java:167)
at BigQueryLocal.loadClientSecrets(BigQueryLocal.java:99)
at BigQueryLocal.<clinit>(BigQueryLocal.java:31)
 Exception in thread "main" java.lang.NullPointerException
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl.   <init>(GoogleAuthorizationCodeRequestUrl.java:111)
at BigQueryLocal.main(BigQueryLocal.java:47)

我不明白的是,我的json文件在同一文件夹中(我尝试了相对和绝对路径)我的JSON文件是这样的:

{
     "installed": {
        "client_id": "XXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
        "client_secret": "XXXXXXXXXXXXXXXXX",
        "redirect_uris": ["urn:ietf:oauth:2.0:oob"],
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://accounts.google.com/o/oauth2/token"
    }
}

我使用Google API库1.12-beta和Java 1.6。所以,我不明白为什么我在那里有这个错误:(,如果有人有想法...

谢谢:)

您正在使用哪个IDE?当您的代码无法找到资源时,这往往会发生,因为它在错误的目录中,或者在目录中,您的应用程序不考虑资源。

例如,有关堆栈溢出的信息,有关处理此操作的信息:我想在哪里放置文本文件?

最新更新