Requirement from the client team is restricting us from using PDX Serialization at the client side.
Gemfire is being used as a caching layer. There is core team which maintains the functionality provided by spring caching abstraction and they bundle the functionality needed for caching data using Gemfire in a jar, which will be consumed by several application teams. They want to abstract the application teams from implementation logic of caching layer backend. So, specifying the objects to be pdxserialized before hand in clientCache.xml is not a option. I believe, better option is to have the domain objects in the classpath of Gemfire Cache servers. Thanks, Nikhil On Thu, Dec 3, 2015 at 2:36 PM, John Blum <[email protected]> wrote: > No. JSONFormatter only works between JSON and PDX. As such, the REST API > does not support Java serialization OOTB. > > On Thu, Dec 3, 2015 at 11:31 AM, Nikhil Chandrappa <[email protected] > > wrote: > >> Thanks everyone for the response. Seems like enabling the PDX on the >> client cache is way to go. >> >> I had one more thought, if I enable the Rest API and query the data >> through rest endpoint. Will Gemfire successfully convert the Java >> serialized object into JSON using JSONFormatter? >> >> Regards, >> Nikhil >> >> >> >> On Thu, Dec 3, 2015 at 2:07 PM, Mark Secrist <[email protected]> wrote: >> >>> I've run into this issue myself. One important thing you need to do that >>> I don't see on the configuration is setting PDX serialization on the >>> client. I've done something like the following: >>> <gfe:client-cache id="clientCache" pool-name="gemfirePool" >>> pdx-serializer-ref="pdxAutoSerializer" /> >>> <bean id="pdxAutoSerializer" >>> class="com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer"> >>> <constructor-arg> >>> <value>classes to serialize</value> >>> </constructor-arg> >>> </bean> >>> >>> That way, as clients are inserting objects, they will be PDX serialized. >>> Another thing I've seen happen is that there are some rules about objects >>> (and contained objects) needing a default (no arg) constructor. If GemFire >>> detects this isn't the case, it will revert to Java Serializable. You can >>> enforce this by adding the 'check-portability' parameter to the serializer >>> constructor. This will cause serialization to fail if you don't meet the >>> requirements for PDX Serialization. >>> >>> Mark >>> >>> On Thu, Dec 3, 2015 at 11:30 AM, Jason Huynh <[email protected]> wrote: >>> >>>> Hi Nikhil, >>>> >>>> For point (a), if the objects are stored as java serializable, I >>>> believe when deserializing on the server, the class files would need to be >>>> on the server class path because at that point it is not pdx serialized. >>>> >>>> I think you would need to have the clients serialize with pdx or else >>>> you will get this behavior. I am not sure but I don't think the server can >>>> automatically convert from java serialization to pdx serialization in this >>>> scenario, especially because the information on how to pdx serialize would >>>> be contained in the class which isn't on the server. >>>> >>>> Even if the server knew about the class file, I am not sure if that >>>> auto conversion would happen once it has been serialized from the client. >>>> Someone that knows pdx a bit better may be able to answer this. >>>> >>>> -Jason >>>> >>>> On Thu, Dec 3, 2015 at 10:12 AM, Nikhil Chandrappa < >>>> [email protected]> wrote: >>>> >>>>> Hi, >>>>> >>>>> *Issue*: >>>>> >>>>> Unable to query the Gemfire region. I get the following exception >>>>> >>>>> gfsh>query --query="SELECT firstName FROM /Account WHERE id=1" >>>>> >>>>> Result : false >>>>> startCount : 0 >>>>> endCount : 20 >>>>> Message : A ClassNotFoundException was thrown while trying to >>>>> deserialize cached value. >>>>> >>>>> NEXT_STEP_NAME : END >>>>> >>>>> *Context*: >>>>> >>>>> We are using Spring Data Gemfire caching for storing the cached >>>>> objects in >>>>> to Gemfire. We want to be able to query the Gemfire region to see the >>>>> cache >>>>> data. >>>>> >>>>> Following are the constraints we have, >>>>> >>>>> 1. we cannot enable the PDX serializer on the client >>>>> 2. Domain objects cannot be placed on the Gemfire server classpath >>>>> >>>>> *Analysis:* >>>>> >>>>> *a)* >>>>> we have configured Gemfire cluster with PDX serialization, however >>>>> Gemfire >>>>> will store the objects as Java Serialized object. is this a valid >>>>> behavior? >>>>> >>>>> *b)* >>>>> If we use the query service like below, >>>>> >>>>> // Log for debugging >>>>> >>>>> cache.getLogger().info("Executing Query: "+ queryStr); >>>>> >>>>> SelectResults results = (SelectResults) query.execute(); >>>>> >>>>> // Log for debugging >>>>> >>>>> cache.getLogger().info("After Query Execution"); >>>>> >>>>> I am getting "A ClassNotFoundException was thrown while trying to >>>>> deserialize cached value." >>>>> >>>>> What are the options that we have for querying the regions with >>>>> constraints >>>>> that are mentioned above? We want to able to query the Gemfire regions >>>>> without having the domain objects present on the classpath. >>>>> >>>>> *Configurations:* >>>>> >>>>> >>>>> ClientCache.xml >>>>> >>>>> <?xml version="1.0" encoding="utf-8"?> >>>>> <beans xmlns="http://www.springframework.org/schema/beans" >>>>> xmlns:cache="http://www.springframework.org/schema/cache" >>>>> xmlns:context="http://www.springframework.org/schema/context" >>>>> xmlns:gfe="http://www.springframework.org/schema/gemfire" >>>>> xmlns:gfe-data=" >>>>> http://www.springframework.org/schema/data/gemfire" >>>>> xmlns:p="http://www.springframework.org/schema/p" >>>>> xmlns:util="http://www.springframework.org/schema/util" >>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>>> xsi:schemaLocation=" >>>>> http://www.springframework.org/schema/beans >>>>> http://www.springframework.org/schema/beans/spring-beans.xsd >>>>> http://www.springframework.org/schema/cache >>>>> http://www.springframework.org/schema/cache/spring-cache.xsd >>>>> http://www.springframework.org/schema/context >>>>> http://www.springframework.org/schema/context/spring-context.xsd >>>>> http://www.springframework.org/schema/gemfire >>>>> http://www.springframework.org/schema/gemfire/spring-gemfire.xsd >>>>> http://www.springframework.org/schema/data/gemfire >>>>> >>>>> http://www.springframework.org/schema/data/gemfire/spring-data-gemfire.xsd >>>>> http://www.springframework.org/schema/util >>>>> http://www.springframework.org/schema/util/spring-util.xsd >>>>> "> >>>>> >>>>> >>>>> <util:properties id="clientConfigurationSettings"> >>>>> <prop key="pivotal.cache.specs.directory">specs</prop> >>>>> </util:properties> >>>>> >>>>> <context:property-placeholder location="classpath:server.properties" >>>>> properties-ref="clientConfigurationSettings"/> >>>>> >>>>> <util:properties id="gemfireCacheConfigurationSettings"> >>>>> <prop key="log-level">config</prop> >>>>> <prop key="cluster-ssl-enabled">true</prop> >>>>> <prop >>>>> >>>>> key="cluster-ssl-truststore">/Users/nchandrappa/Documents/grid/security/cacerts.keystore</prop> >>>>> <prop key="cluster-ssl-truststore-password">password</prop> >>>>> </util:properties> >>>>> >>>>> <gfe:pool id="serverConnectionPool"> >>>>> <gfe:locator host="localhost" port="10334"/> >>>>> </gfe:pool> >>>>> >>>>> <gfe:client-cache properties-ref="gemfireCacheConfigurationSettings" >>>>> id="gemfireCache" pool-name="serverConnectionPool"/> >>>>> >>>>> <cache:annotation-driven/> >>>>> >>>>> <bean id="cacheManager" >>>>> >>>>> class="pivotal.gemfire.core.cache.manager.RegionCreationGemFireCacheManager" >>>>> p:cache-ref="gemfireCache"/> >>>>> <bean class="pivotal.gemfire.core.cache.manager.RegionCreator" /> >>>>> >>>>> <context:component-scan base-package="pivotal.client"/> >>>>> >>>>> </beans> >>>>> >>>>> >>>>> ServerCache.xml >>>>> >>>>> <?xml version="1.0"?> >>>>> <!DOCTYPE cache PUBLIC >>>>> "-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN" >>>>> "http://www.gemstone.com/dtd/cache8_0.dtd"> >>>>> >>>>> <cache> >>>>> <pdx read-serialized="true" /> >>>>> </cache> >>>>> >>>>> Thanks, >>>>> Nikhil >>>>> >>>> >>>> >>> >>> >>> -- >>> >>> *Mark Secrist | Sr Manager, **Global Education Delivery* >>> >>> [email protected] >>> >>> 970.214.4567 Mobile >>> >>> *pivotal.io <http://www.pivotal.io/>* >>> >>> Follow Us: Twitter <http://www.twitter.com/pivotal> | LinkedIn >>> <http://www.linkedin.com/company/pivotalsoftware> | Facebook >>> <http://www.facebook.com/pivotalsoftware> | YouTube >>> <http://www.youtube.com/gopivotal> | Google+ >>> <https://plus.google.com/105320112436428794490> >>> >> >> > > > -- > -John > 503-504-8657 > john.blum10101 (skype) >
