You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by PereTang <ta...@outlook.com> on 2020/02/05 08:41:53 UTC

ClassCastException on Thin client when get cache value with List and Map

I use the thin java client.


I Create a ArrayList and put the Person object into it.
----------------------------------------------------------------------
try (IgniteClient igniteClient = Ignition.startClient(new
ClientConfiguration().setAddresses("127.0.0.1:10800"))) {
    final ClientCache<String, List&lt;Person>> demo =
igniteClient.getOrCreateCache("demo");
    final List<Person> personList = new java.util.ArrayList<>();
    personList.add(new Person("apache", 100));
    personList.add(new Person("Ignite", 13));
    demo.put("test", personList);
}
----------------------------------------------------------------------

And when I take it out of the list
----------------------------------------------------------------------
try (IgniteClient igniteClient = Ignition.startClient(new
ClientConfiguration().setAddresses("127.0.0.1:10800"))) {
    final ClientCache<String, List&lt;Person>> demo =
igniteClient.getOrCreateCache("demo");
    final List<Person> personList = demo.get("test");
    final Person person = personList.get(0);
}
----------------------------------------------------------------------

I get the following exceptions:
----------------------------------------------------------------------
java.lang.ClassCastException: class
org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to class
com.peeandgee.Person (org.apache.ignite.internal.binary.BinaryObjectImpl and
com.peeandgee.Person are in unnamed module of loader 'app')
----------------------------------------------------------------------

However, there is no exception if I modify the code as follows:
----------------------------------------------------------------------
BinaryObject bo = (BinaryObject) map.get(0);
Person person = bo.deserialize();
----------------------------------------------------------------------


Same issue in Map [ClassCastException on thinClient in Apache
Ignite|https://stackoverflow.com/questions/59299316/classcastexception-on-thinclient-in-apache-ignite]



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: ClassCastException on Thin client when get cache value with List and Map

Posted by Ivan Pavlukhin <vo...@gmail.com>.
Hi,

Indeed it is a bug. We are already working on it in scope of
https://issues.apache.org/jira/browse/IGNITE-12468

ср, 5 февр. 2020 г. в 11:42, PereTang <ta...@outlook.com>:
>
> I use the thin java client.
>
>
> I Create a ArrayList and put the Person object into it.
> ----------------------------------------------------------------------
> try (IgniteClient igniteClient = Ignition.startClient(new
> ClientConfiguration().setAddresses("127.0.0.1:10800"))) {
>     final ClientCache<String, List&lt;Person>> demo =
> igniteClient.getOrCreateCache("demo");
>     final List<Person> personList = new java.util.ArrayList<>();
>     personList.add(new Person("apache", 100));
>     personList.add(new Person("Ignite", 13));
>     demo.put("test", personList);
> }
> ----------------------------------------------------------------------
>
> And when I take it out of the list
> ----------------------------------------------------------------------
> try (IgniteClient igniteClient = Ignition.startClient(new
> ClientConfiguration().setAddresses("127.0.0.1:10800"))) {
>     final ClientCache<String, List&lt;Person>> demo =
> igniteClient.getOrCreateCache("demo");
>     final List<Person> personList = demo.get("test");
>     final Person person = personList.get(0);
> }
> ----------------------------------------------------------------------
>
> I get the following exceptions:
> ----------------------------------------------------------------------
> java.lang.ClassCastException: class
> org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to class
> com.peeandgee.Person (org.apache.ignite.internal.binary.BinaryObjectImpl and
> com.peeandgee.Person are in unnamed module of loader 'app')
> ----------------------------------------------------------------------
>
> However, there is no exception if I modify the code as follows:
> ----------------------------------------------------------------------
> BinaryObject bo = (BinaryObject) map.get(0);
> Person person = bo.deserialize();
> ----------------------------------------------------------------------
>
>
> Same issue in Map [ClassCastException on thinClient in Apache
> Ignite|https://stackoverflow.com/questions/59299316/classcastexception-on-thinclient-in-apache-ignite]
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/



-- 
Best regards,
Ivan Pavlukhin