Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-12468

ClassCastException on thinClient in Apache Ignite

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.6
    • 2.9, 2.8.1
    • binary, clients, thin client
    • None
    • Docs Required, Release Notes Required

    Description

       

          ClientConfiguration cfg = new ClientConfiguration().setAddresses("127.0.0.1:10800");
      
          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();
      
              //put
              HashMap<Integer, Person> hm = new HashMap<Integer, Person>();
              hm.put(1, p);
              cache.put(1, hm);
      
              //get
              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) {
              System.err.println(e.getMessage());
              e.printStackTrace();
          }
          catch (Exception e) {
              System.err.format("Unexpected failure: %s\n", e);
              e.printStackTrace();
          }
      

       

      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?

       

      Attachments

        Issue Links

          Activity

            People

              alex_pl Aleksey Plekhanov
              redcomet LEE PYUNG BEOM
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h