ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "LEE PYUNG BEOM (Jira)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-12468) ClassCastException on thinClient in Apache Ignite
Date Thu, 19 Dec 2019 01:35:00 GMT
LEE PYUNG BEOM created IGNITE-12468:

             Summary: ClassCastException on thinClient in Apache Ignite
                 Key: IGNITE-12468
                 URL: https://issues.apache.org/jira/browse/IGNITE-12468
             Project: Ignite
          Issue Type: Bug
          Components: clients
    Affects Versions: 2.6
            Reporter: LEE PYUNG BEOM

    ClientConfiguration cfg = new ClientConfiguration().setAddresses("");

    try (IgniteClient igniteClient = Ignition.startClient(cfg)) {

        System.out.println(">>> Thin client put-get example started.");

        final String CACHE_NAME = "put-get-example";

        ClientCache<Integer, Object> cache = igniteClient.getOrCreateCache(CACHE_NAME);

        Person p = new Person();

        HashMap<Integer, Person> hm = new HashMap<Integer, Person>();
        hm.put(1, p);
        cache.put(1, hm);

        HashMap<Integer, Person> map = (HashMap<Integer, Person>)cache.get(1);
        Person p2 = map.get(1);

        System.out.format(">>> Loaded [%s] from the cache.\n",p2);

    catch (ClientException e) {
    catch (Exception e) {
        System.err.format("Unexpected failure: %s\n", e);

I use the thin client of apache-ignite.

I Create a hashmap and put the Person class(org.apache.ignite.examples.model.Person) object
into it.

And when I take it out of the hashmap, I get the following exceptions:

> java.lang.ClassCastException:
> org.apache.enite.internal.binary.BinaryObjectImpl cannot be cast to
> org.apache.engite.examples.model.Person.
An exception is given in the code below.

Person p2 = map.get(1);

However, there is no exception if I modify the code as follows:

BinaryObject bo = (BinaryObject) map.get(1);

Person p2 = bo.deserialize();
I don't think that's necessary. Is there another solution?


This message was sent by Atlassian Jira

View raw message