2017-01-13 3 views
1

문서의 단계를 따라 갔지만이 예외가 계속 발생했다고 생각합니다. (이클립스 J2EE에서 실행하는 유일한 차이점은, 실제로는 그렇지 않겠습니까?)wordcount 예제를 실행할 때 Apache Beam 예외

코드 : 빔 프로젝트 예제에서 작성했습니다.). Google 클라우드 플랫폼 프로젝트를 지정하고 액세스 권한을 부여해야합니다. 그러나이 예제 프로젝트에서 설정을 수행하는 곳을 찾지 못했습니다.

public static void main(String[] args) { 
// Create a PipelineOptions object. This object lets us set various execution 
// options for our pipeline, such as the runner you wish to use. This example 
// will run with the DirectRunner by default, based on the class path configured 
// in its dependencies. 
PipelineOptions options = PipelineOptionsFactory.create(); 

// Create the Pipeline object with the options we defined above. 
Pipeline p = Pipeline.create(options); 

// Apply the pipeline's transforms. 

// Concept #1: Apply a root transform to the pipeline; in this case, TextIO.Read to read a set 
// of input text files. TextIO.Read returns a PCollection where each element is one line from 
// the input text (a set of Shakespeare's texts). 

// This example reads a public data set consisting of the complete works of Shakespeare. 
p.apply(TextIO.Read.from("gs://apache-beam-samples/shakespeare/*")) 
..... 
) 

예외 : Windows를 사용하는 경우 명령 프롬프트에서 실행하는

Exception in thread "main" java.lang.IllegalStateException: Failed to validate gs://apache-beam-samples/shakespeare/* 
at org.apache.beam.sdk.io.TextIO$Read$Bound.expand(TextIO.java:309) 
at org.apache.beam.sdk.io.TextIO$Read$Bound.expand(TextIO.java:205) 
at org.apache.beam.sdk.runners.PipelineRunner.apply(PipelineRunner.java:76) 
at org.apache.beam.runners.direct.DirectRunner.apply(DirectRunner.java:296) 
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:388) 
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:302) 
at org.apache.beam.sdk.values.PBegin.apply(PBegin.java:47) 
at org.apache.beam.sdk.Pipeline.apply(Pipeline.java:152) 
at google.dataflow.beam.example.MinimalWordCount.main(MinimalWordCount.java:77) 
Caused by: java.io.IOException: Unable to match files in bucket apache-beam-samples, prefix shakespeare/ against pattern shakespeare/[^/]* 
at org.apache.beam.sdk.util.GcsUtil.expand(GcsUtil.java:234) 
at org.apache.beam.sdk.util.GcsIOChannelFactory.match(GcsIOChannelFactory.java:53) 
at org.apache.beam.sdk.io.TextIO$Read$Bound.expand(TextIO.java:304) 
... 8 more 
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request 
{ 


"error" : "invalid_grant" 
} 
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1070) 
    at com.google.auth.oauth2.UserCredentials.refreshAccessToken(UserCredentials.java:207) 
    at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:149) 
    at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:135) 
    at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96) 
    at com.google.cloud.hadoop.util.ChainingHttpRequestInitializer.initialize(ChainingHttpRequestInitializer.java:52) 
    at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:300) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) 
    at com.google.cloud.hadoop.util.ResilientOperation$AbstractGoogleClientRequestExecutor.call(ResilientOperation.java:166) 
    at com.google.cloud.hadoop.util.ResilientOperation.retry(ResilientOperation.java:66) 
    at com.google.cloud.hadoop.util.ResilientOperation.retry(ResilientOperation.java:103) 
    at org.apache.beam.sdk.util.GcsUtil.expand(GcsUtil.java:227) 
    ... 10 more 
+0

코드를 게시하십시오. –

+0

코드가 있습니다. – foxwendy

+1

'gcloud'를 사용하여 명령 줄에서 인증을 받았습니까? https://cloud.google.com/dataflow/security-and-permissions –

답변

1

보십시오. pom.xml 파일이있는 폴더로 이동하여 cmd를 엽니 다. 다음 각 인수와 함께 명령을 제공하십시오.

mvn compile exec:java -Dexec.mainClass=org.apache.beam.examples.WordCount -Dexec.args=" --output=counts" -Pdirect-runner 

입력 파일로 실행하려면. 그런 다음 이름이 txt 인 파일을 만들어 pom이 들어있는 폴더에 넣습니다. 그리고 사격 명령을 내린다.

mvn compile exec:java -Dexec.mainClass=org.apache.beam.examples.WordCount -Dexec.args="--inputFile=YOURFILENAME.txt --output=counts" -Pdirect-runner** 

희망. 나머지 귀하의 문제를 조사하고 있습니다

관련 문제