2

I'm trying to use gemfire rest api with gemfire native client. What I have working:

  1. crud for my object via native client
  2. retrieve and delete of the same object via rest api

When I try to perform the create/update via rest api with @type and then try to get it via gemfire native client I get

"com.gemstone.gemfire.pdx.internal.PdxInstanceImpl cannot be cast to...

I checked Docs: https://gemfire.docs.pivotal.io/95/geode/rest_apps/rest_prereqs.html and:

To achieve interoperability between GemFire Java clients (or GemFire native clients) and REST clients, the following rules must be followed:

  1. All GemFire Java and native client classes operating on data also accessed by the REST interface must be PDX serialized, either via PDX autoserialization or by implementing PdxSerializable.
  2. GemFire Java clients and native clients can retrieve REST-enabled data either as a PdxInstance or as an actual object by using the PdxInstance.getObject method. If you use the latter method, you must first declare the object type (@type) in your POST or PUT request payload when creating the object in REST; and secondly, the Java client must have the actual domain class in its CLASSPATH.

I see I have PDX autoserialization working in my case. So I execute create/update request. But @type isn't handled as I expected.

I have gemfire version 8.2.0

My only solution is to implement PdxSerializable ?

A basic example of what I do:

My object Person has fields: id, name. It is located at com.package.

  1. I save my object with gemfire native client.
  2. I execute Http PUT request /gemfire-api/v1/{region}/{key} with payload: '{ "@type":"com.package.Person", "id":"someId", "name":"name" }'
  3. I try to retrieve it with HTTP GET - successfully
  4. I try to retrieve it with gemfire native client and cast it to Person object with getObject() - I have an error
Community
  • 1
  • 1
Rostislav V
  • 1,706
  • 1
  • 19
  • 31

0 Answers0