google API Bigquery null指针java

时间:2021-08-05 14:55:59

I tried setting up a BigQuery project with a JAVA API to access it. But when I run the google BigQueryInstalledAuthDemo class which is here, I get this error :

我尝试使用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)

Which I don't understand, my JSON file is in the same folder than the class (I tried both relative and absolute paths) My JSON file is like this :

我不明白,我的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"
    }
}

I use the google API library 1.12-beta and java 1.6. So, I don't understand why I have this error right there :(, so if anyone has an idea...

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

Thank you :)

谢谢 :)

1 个解决方案

#1


0  

Which IDE are you using? This tends to happen when your code can't locate the resource, because it is in the wrong directory, or is in a directory that your app doesn't consider a resource.

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

There's a lot of info on Stack Overflow about handling this, for example: Where to put a textfile I want to use in eclipse?

Stack Overflow上有很多关于处理它的信息,例如:在eclipse中放置一个我想要使用的文本文件?

#1


0  

Which IDE are you using? This tends to happen when your code can't locate the resource, because it is in the wrong directory, or is in a directory that your app doesn't consider a resource.

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

There's a lot of info on Stack Overflow about handling this, for example: Where to put a textfile I want to use in eclipse?

Stack Overflow上有很多关于处理它的信息,例如:在eclipse中放置一个我想要使用的文本文件?