Unable to use Scala's BeanProperty with classes

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to use Scala's BeanProperty with classes

Adarsh Jain

I am getting the same problem when trying to do FlatMap operation on my POJO class.

Exception in thread "main" java.lang.IllegalStateException: Detected more than one setter


Am using Flink 1.2, the exception is coming when using FlatMap




Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Nico Kruber
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:

> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070


signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Adarsh Jain
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070


Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Fabian Hueske-2
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070



Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Adarsh Jain
Thanks Fabian, I need to sink data in Cassandra and direct sink with case class is not available (correct me if I am wrong)

If we use Tuple then we are restricted to 22 fields

What do you suggest here?




On Wed, Feb 15, 2017 at 2:32 PM, Fabian Hueske <[hidden email]> wrote:
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070




Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Timo Walther
Hi Adarsh,

I looked into your issue. The problem is that `var` generates Scala-style getters/setters and the annotation generates Java-style getters/setters. Right now Flink only supports one style in a POJO, I don't know why we have this restriction. I will work on a fix for that. Is it possible for you to remove the `var`? According to this Stackoverflow it is also considered a bad practice: http://stackoverflow.com/questions/35038977/is-it-good-practice-to-use-beanproperty-in-scala-instead-of-defining-getter-set

Regards,
Timo




Am 15/02/17 um 10:08 schrieb Adarsh Jain:
Thanks Fabian, I need to sink data in Cassandra and direct sink with case class is not available (correct me if I am wrong)

If we use Tuple then we are restricted to 22 fields

What do you suggest here?




On Wed, Feb 15, 2017 at 2:32 PM, Fabian Hueske <[hidden email]> wrote:
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070





Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Chesnay Schepler
In reply to this post by Adarsh Jain
Hello,

There is an open PR about adding support for case classes to the cassandra sinks: https://github.com/apache/flink/pull/2633

You would have to checkout the branch and build it yourself. If this works for you it would be great if you could also give some
feedback either here or in the PR.

Regards,
Chesnay

On 15.02.2017 10:08, Adarsh Jain wrote:
Thanks Fabian, I need to sink data in Cassandra and direct sink with case class is not available (correct me if I am wrong)

If we use Tuple then we are restricted to 22 fields

What do you suggest here?




On Wed, Feb 15, 2017 at 2:32 PM, Fabian Hueske <[hidden email]> wrote:
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070





Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Timo Walther
Forget what I said about omitting `var`, this would remove the field from the POJO. I opened a PR for fixing the issue: https://github.com/apache/flink/pull/3318

As a workaround: If you just want to have a POJO for the Cassandra Sink you don't need to add the `@BeanProperty` annotation. Flink supports also Scala-style POJOs. You just have to make sure that your class contains a default constructor.

This is a valid POJO:

  class SomeClass(var prop: Int) {
    def this() = this(0)
  }

I hope that helps.

Timo


Am 15/02/17 um 10:48 schrieb Chesnay Schepler:
Hello,

There is an open PR about adding support for case classes to the cassandra sinks: https://github.com/apache/flink/pull/2633

You would have to checkout the branch and build it yourself. If this works for you it would be great if you could also give some
feedback either here or in the PR.

Regards,
Chesnay

On 15.02.2017 10:08, Adarsh Jain wrote:
Thanks Fabian, I need to sink data in Cassandra and direct sink with case class is not available (correct me if I am wrong)

If we use Tuple then we are restricted to 22 fields

What do you suggest here?




On Wed, Feb 15, 2017 at 2:32 PM, Fabian Hueske <[hidden email]> wrote:
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070






Reply | Threaded
Open this post in threaded view
|

Re: Unable to use Scala's BeanProperty with classes

Adarsh Jain
Thanks Timo, removing  `@BeanProperty`  is giving no getters, no setters error




On Wed, Feb 15, 2017 at 3:45 PM, Timo Walther <[hidden email]> wrote:
Forget what I said about omitting `var`, this would remove the field from the POJO. I opened a PR for fixing the issue: https://github.com/apache/flink/pull/3318

As a workaround: If you just want to have a POJO for the Cassandra Sink you don't need to add the `@BeanProperty` annotation. Flink supports also Scala-style POJOs. You just have to make sure that your class contains a default constructor.

This is a valid POJO:

  class SomeClass(var prop: Int) {
    def this() = this(0)
  }

I hope that helps.

Timo


Am 15/02/17 um 10:48 schrieb Chesnay Schepler:
Hello,

There is an open PR about adding support for case classes to the cassandra sinks: https://github.com/apache/flink/pull/2633

You would have to checkout the branch and build it yourself. If this works for you it would be great if you could also give some
feedback either here or in the PR.

Regards,
Chesnay

On 15.02.2017 10:08, Adarsh Jain wrote:
Thanks Fabian, I need to sink data in Cassandra and direct sink with case class is not available (correct me if I am wrong)

If we use Tuple then we are restricted to 22 fields

What do you suggest here?



<img class="m_-7292957982195133284mailtrack-img" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" height="0" width="0">

On Wed, Feb 15, 2017 at 2:32 PM, Fabian Hueske <[hidden email]> wrote:
Hi Adarsh,

I think this is the same bug. I'm afraid you have to wait until the problem is fixed.
The only workaround would be to use a different data type, for example a case class.

Best, Fabian

2017-02-15 6:08 GMT+01:00 Adarsh Jain <[hidden email]>:
Any help will be highly appreciable, am stuck on this one.






On Tue, Feb 14, 2017 at 10:47 PM, Nico Kruber <[hidden email]> wrote:
Hi Adarsh,
thanks for reporting this. It should be fixed eventually.

@Timo: do you have an idea for a work-around or quick-fix?


Regards
Nico

On Tuesday, 14 February 2017 21:11:21 CET Adarsh Jain wrote:
> I am getting the same problem when trying to do FlatMap operation on my
> POJO class.
>
> Exception in thread "main" java.lang.IllegalStateException: Detected
> more than one setter
>
>
>
> Am using Flink 1.2, the exception is coming when using FlatMap
>
> https://issues.apache.org/jira/browse/FLINK-5070