私はGoogle App Engineを初めて使いました。これは私の組織でこれがどのように機能するかを見るためにいくつかのチュートリアルを実行しようとしています。私たちはいくつかのデータをBigQueryに入れ、いくつかのWebアプリケーションをApp Engineに変換し、BigQueryデータにアクセスする必要があります。EclipseのローカルApp EngineインスタンスからBigQueryに接続できません
私は、コマンドからこれを実行することができ、具体的にBigQuery /クラウド型クライアント/ srcに/メイン/ javaの/ COM /例/ BigQueryの/ SimpleApp.java
、Javaベースのドキュメント・サンプル・マスターコードを使用しています私は、App Engineのにコードを組み込み、私はEclipseで実行していたと私はまだ、コマンドラインから実行することができるようにラッパーを作成し
mvn exec:java -Dexec.mainClass=com.example.bigquery.SimpleAppMain
を使用して行。コマンドラインから実行すると動作しますが、EclipseのApp Engineから実行するとエラーが発生します。
私のローカルApp EngineをBig Queryに接続するための設定がありませんか?
エラー:
com.google.cloud.bigquery.BigQueryException: Invalid project ID 'no_app_id'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a letter and may not end with a dash.
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.translate(HttpBigQueryRpc.java:86)
at com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.create(HttpBigQueryRpc.java:170)
at com.google.cloud.bigquery.BigQueryImpl$3.call(BigQueryImpl.java:208)
...
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400
{ "code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid project ID 'no_app_id'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a letter and may not end with a dash.",
"reason" : "invalid"
} ],
"message" : "Invalid project ID 'no_app_id'. Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a letter and may not end with a dash."
}
はコード: "no_app_id":あなたのエラーコードのルックスから
package com.example.bigquery;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.FieldValue;
import com.google.cloud.bigquery.Job;
import com.google.cloud.bigquery.JobId;
import com.google.cloud.bigquery.JobInfo;
import com.google.cloud.bigquery.QueryJobConfiguration;
import com.google.cloud.bigquery.QueryResponse;
import com.google.cloud.bigquery.QueryResult;
import java.util.List;
import java.util.UUID;
public class SimpleApp {
public void runBQ() throws Exception {
// [START create_client]
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
// [END create_client]
// [START run_query]
QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(
"SELECT "
+ "APPROX_TOP_COUNT(corpus, 10) as title, "
+ "COUNT(*) as unique_words "
+ "FROM `publicdata.samples.shakespeare`;")
// Use standard SQL syntax for queries.
// See: https://cloud.google.com/bigquery/sql-reference/
.setUseLegacySql(false)
.build();
// Create a job ID so that we can safely retry.
JobId jobId = JobId.of(UUID.randomUUID().toString());
Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build());
// Wait for the query to complete.
queryJob = queryJob.waitFor();
// Check for errors
if (queryJob == null) {
throw new RuntimeException("Job no longer exists");
} else if (queryJob.getStatus().getError() != null) {
// You can also look at queryJob.getStatus().getExecutionErrors() for all
// errors, not just the latest one.
throw new RuntimeException(queryJob.getStatus().getError().toString());
}
// Get the results.
QueryResponse response = bigquery.getQueryResults(jobId);
// [END run_query]
// [START print_results]
QueryResult result = response.getResult();
// Print all pages of the results.
while (result != null) {
for (List<FieldValue> row : result.iterateAll()) {
List<FieldValue> titles = row.get(0).getRepeatedValue();
System.out.println("titles:");
for (FieldValue titleValue : titles) {
List<FieldValue> titleRecord = titleValue.getRecordValue();
String title = titleRecord.get(0).getStringValue();
long uniqueWords = titleRecord.get(1).getLongValue();
System.out.printf("\t%s: %d\n", title, uniqueWords);
}
long uniqueWords = row.get(1).getLongValue();
System.out.printf("total unique words: %d\n", uniqueWords);
}
result = result.getNextPage();
}
// [END print_results]
}
}
私があなたが提供したリンクを見ましたが、私はプロジェクトを右クリックするとGoogleのメニューオプションがありません。 FYI - 「Eclipse 4.5およびそれ以降のGoogle Cloud Platform」プラグインがインストールされています。私が見ることのできるところには古い "Google Plugin for Eclipse"がありますが、それは私がインストールした他のプラグインをアンインストールしたいのです。私は行方不明の何か他にありますか? – RyanD
ファイルに存在するかどうかを確認できますか:「特定のApp EngineプロジェクトのプロジェクトIDとバージョンは、war/WEB-INFディレクトリにあるappengine-web.xmlファイルで定義されていますか? –
私はいずれもappengine-web.xmlにリストされていません。フォーマットを調べて、とのタグを追加しました。「プロジェクトIDは展開時に指定する必要があります」という警告が表示されます。 –
RyanD