Hi Antony, Thanks for the report!
You are right about the easiest way to fix this: use Create.withCoder(...). It is generally the best practice as Create actually infers coders in a way that is different from everywhere else (we would like this to be invisible, but unfortunately we cannot quite make it so). But I also think that (1) your example should work and use SerializableCoder and (2) the error message you saw is not good enough. So I have filed https://issues.apache.org/jira/browse/BEAM-1736 Kenn On Mon, Mar 13, 2017 at 8:28 AM, Antony Mayi <antonym...@yahoo.com> wrote: > to answer myself: > > I should have said I am creating the PCollection<Data> using Create.of > which apparently leads to this getDefaultCoder() implementation: > CoderRegistry.getDefaultCoder(T exampleValue) > <https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L257> > which > doesn't try inspecting the annotation (as opposed > CoderRegistry.getDefaultCoder(Class<T> clazz) > <https://github.com/apache/beam/blob/release-0.5.0/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L313> > ). > So I guess I have to explicitly use the create.of().withCoder(). > > antony. > > > On Monday, 13 March 2017, 13:37, Antony Mayi <antonym...@yahoo.com> wrote: > > > Hi, > > trying to create PCollection of my custom data class but keep failing due > to the CannotProvideCoderException: > > My class is declared as follows: > > @DefaultCoder(SerializableCoder.class) public class Data<DataT extends > BaseData> implements Serializable { > > and it fails like this: > > Caused by: org.apache.beam.sdk.coders.CannotProvideCoderException: Cannot > provide coder based on value with class my.project.Data: No CoderFactory > has been registered for the class. > > why it doesn't pick the coder? > > thanks, > Antony. > > >