Repository navigation
Closed
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
I’m trying to receive some Data from google BigQuery and show the result in my eclipse console to get started with BigQuery and Java. Basically, I followed the Instructions provided by google, which I found here: https://cloud.google.com/bigquery/docs/reference/libraries
So my example Java Code looks like the quick start example from google:
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Dataset;
import com.google.cloud.bigquery.DatasetInfo;
public class QuickstartSample {
public static void main(String... args){
// Instantiates a client
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
// The name for the new dataset
String datasetName = "bigquery-public-data:hacker_news.comments";
// Prepares a new dataset
Dataset dataset = null;
DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build();
// Creates the dataset
dataset = bigquery.create(datasetInfo);
System.out.printf("Dataset %s created.%n", dataset.getDatasetId().getDataset());
}
}
But when I run this Code I get the following error:
HTTP ERROR 500
Problem accessing /getbigquery. Reason:
Could not get the access token.
Caused by:
com.google.cloud.bigquery.BigQueryException: Could not get the access token.
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.translate(HttpBigQueryRpc.java:86)
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.create(HttpBigQueryRpc.java:141)
at com.google.cloud.bigquery.BigQueryImpl$1.call(BigQueryImpl.java:172)
at com.google.cloud.bigquery.BigQueryImpl$1.call(BigQueryImpl.java:169)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:94)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:54)
at com.google.cloud.bigquery.BigQueryImpl.create(BigQueryImpl.java:169)
at testpackage.dto.QuickstartSample.main(QuickstartSample.java:27)
at testpackage.getbigquery.doPost(getbigquery.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
I tried to authenticate with Default Credentials so I ran “gcloud auth application-default login“ in my google SDK console. Although I could login in SDK, eclipse gave me the previous shown error.
Then I tried a few other things like downloading my token as Json file and revering to it with java in my application or setting my environment variable manually but it didn’t work as well.
Does anyone have an idea what I’m doing wrong? Any help is appreciated.
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Activity
michaelbausor commentedon Aug 23, 2017
Hi @Electricks94,
It looks like you are trying to fetch an existing dataset, but your code is creating it. Can you try the following code to see if you get the same problem?
Electricks94 commentedon Aug 23, 2017
Thank you very much! This worked well.
Just that I understand correctly. What I did with the code I posted was creating a new table in bigquery, but what I really wanted to do was to fetch data from bigquery and that’s why the code didn’t work?
michaelbausor commentedon Aug 23, 2017
Yes, I think so. Your code was trying to create a dataset in the public
bigquery-public-dataproject. The code I suggested did the following:BigQueryobjectI am closing this issue now, but if you have any more problems, please feel free to reopen it!
Electricks94 commentedon Aug 23, 2017
Thanks again for your help.
Now I can receive some basic Information about my tables. I tried to run this code to get started with BigQuery and Java.
What I really want to do is get complete rows as arrays and show the information in Chars.
I did not find options to get complete rows in the methods of the BigQuery object.
So, my Questions are:
Do I need to set up a Pipeline or is there an easier way?
Is this a good thing to do or is there an even better way to show the information stored in BigQuery as Chars?
I’m sorry to ask this question here although it’s not really related to my original question.
Should I open another Question in the issues or is there something else I should do to ask such Questions? (Please excuse my behavior. I’m very new to Github)
michaelbausor commentedon Aug 23, 2017
No worries!
I would try working through some of the How-To guides for Bigquery, available here: https://cloud.google.com/bigquery/docs/how-to
You should find something there that can help - if you want all of the data in a table, take a look at the Using Tables how-tos: https://cloud.google.com/bigquery/docs/tables
If you have other problems, it is best to open another issue, rather than commenting on this one.
Electricks94 commentedon Aug 23, 2017
Thank you very much!
deps: update dependency com.google.cloud:google-cloud-shared-dependen…
chore(main): release 3.0.1 (#2369)
deps: update dependency org.springframework.boot:spring-boot-starter-…
chore: Update generation configuration at Fri Mar 14 02:21:49 UTC 2025 (
chore: Update generation configuration at Fri Mar 14 02:21:49 UTC 2025 (
chore: stop referencing googleapis/sdk-platform-java (#2370)
feat: add internal "deadline remaining" client side metric googleapis…