[
https://issues.apache.org/jira/browse/BEAM-2965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16170240#comment-16170240
]
Ben Menasha commented on BEAM-2965:
-----------------------------------
Please find a complete example pipeline as shown in this issue here:
https://storage.googleapis.com/beam-2965-issue/pubsubtemplate.zip
Thanks
> PubsubIO.fromSubscription(ValueProvider) throws RuntimeException
> ------------------------------------------------------------------
>
> Key: BEAM-2965
> URL: https://issues.apache.org/jira/browse/BEAM-2965
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-gcp
> Affects Versions: 2.1.0
> Reporter: Ben Menasha
> Assignee: Chamikara Jayalath
>
> The very simple Pipeline:
> public class PubsubTemplate {
> public interface PubsubTemplateOptions extends PipelineOptions {
> ValueProvider<String> getSubscription();
> void setSubscription(ValueProvider<String> value);
> }
> public static void main(String[] args) throws IOException {
> PubsubTemplateOptions options =
> PipelineOptionsFactory.fromArgs(args).withValidation()
> .as(PubsubTemplateOptions.class);
> Pipeline p = Pipeline.create(options);
> p.apply(PubsubIO.readStrings().
> fromSubscription(options.getSubscription()));
> p.run().waitUntilFinish();
> }
> }
> Throws the exception when generating a Dataflow template:
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.RuntimeException: Not called from a runtime context.
> at
> org.apache.beam.sdk.options.ValueProvider$RuntimeValueProvider.get(ValueProvider.java:223)
> at
> org.apache.beam.sdk.options.ValueProvider$NestedValueProvider.get(ValueProvider.java:131)
> at
> org.apache.beam.sdk.options.ValueProvider$NestedValueProvider.get(ValueProvider.java:131)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubUnboundedSource.getSubscription(PubsubUnboundedSource.java:1374)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubUnboundedSource$PubsubSource.<init>(PubsubUnboundedSource.java:1103)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubUnboundedSource.expand(PubsubUnboundedSource.java:1407)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubUnboundedSource.expand(PubsubUnboundedSource.java:110)
> at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
> at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:454)
> at org.apache.beam.sdk.values.PBegin.apply(PBegin.java:44)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubIO$Read.expand(PubsubIO.java:730)
> at
> org.apache.beam.sdk.io.gcp.pubsub.PubsubIO$Read.expand(PubsubIO.java:536)
> at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
> at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:454)
> at org.apache.beam.sdk.values.PBegin.apply(PBegin.java:44)
> at org.apache.beam.sdk.Pipeline.apply(Pipeline.java:165)
> at com.google.pubsubtemplate.PubsubTemplate.main(PubsubTemplate.java:34)
> ... 6 more
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)