You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geode.apache.org by Nikhil Chandrappa <nc...@pivotal.io> on 2015/12/03 19:12:11 UTC

Question on Querying and PDX Serialization

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

Re: Question on Querying and PDX Serialization

Posted by Mark Secrist <ms...@pivotal.io>.
That would be the only other option.

On Thu, Dec 3, 2015 at 1:56 PM, Nikhil Chandrappa <nc...@pivotal.io>
wrote:

> 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 <jb...@pivotal.io> 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 <
>> nchandrappa@pivotal.io> 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 <ms...@pivotal.io>
>>> 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 <jh...@pivotal.io> 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 <
>>>>> nchandrappa@pivotal.io> 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*
>>>>
>>>> msecrist@pivotal.io
>>>>
>>>> 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)
>>
>
>


-- 

*Mark Secrist | Sr Manager, **Global Education Delivery*

msecrist@pivotal.io

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>

Re: Question on Querying and PDX Serialization

Posted by Mark Secrist <ms...@pivotal.io>.
That would be the only other option.

On Thu, Dec 3, 2015 at 1:56 PM, Nikhil Chandrappa <nc...@pivotal.io>
wrote:

> 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 <jb...@pivotal.io> 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 <
>> nchandrappa@pivotal.io> 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 <ms...@pivotal.io>
>>> 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 <jh...@pivotal.io> 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 <
>>>>> nchandrappa@pivotal.io> 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*
>>>>
>>>> msecrist@pivotal.io
>>>>
>>>> 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)
>>
>
>


-- 

*Mark Secrist | Sr Manager, **Global Education Delivery*

msecrist@pivotal.io

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>

Re: Question on Querying and PDX Serialization

Posted by Nikhil Chandrappa <nc...@pivotal.io>.
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 <jb...@pivotal.io> 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 <nchandrappa@pivotal.io
> > 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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>>>> nchandrappa@pivotal.io> 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*
>>>
>>> msecrist@pivotal.io
>>>
>>> 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)
>

Re: Question on Querying and PDX Serialization

Posted by Nikhil Chandrappa <nc...@pivotal.io>.
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 <jb...@pivotal.io> 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 <nchandrappa@pivotal.io
> > 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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>>>> nchandrappa@pivotal.io> 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*
>>>
>>> msecrist@pivotal.io
>>>
>>> 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)
>

Re: Question on Querying and PDX Serialization

Posted by John Blum <jb...@pivotal.io>.
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 <nc...@pivotal.io>
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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>>> nchandrappa@pivotal.io> 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*
>>
>> msecrist@pivotal.io
>>
>> 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)

Re: Question on Querying and PDX Serialization

Posted by John Blum <jb...@pivotal.io>.
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 <nc...@pivotal.io>
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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>>> nchandrappa@pivotal.io> 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*
>>
>> msecrist@pivotal.io
>>
>> 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)

Re: Question on Querying and PDX Serialization

Posted by Nikhil Chandrappa <nc...@pivotal.io>.
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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>> nchandrappa@pivotal.io> 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*
>
> msecrist@pivotal.io
>
> 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>
>

Re: Question on Querying and PDX Serialization

Posted by Nikhil Chandrappa <nc...@pivotal.io>.
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 <ms...@pivotal.io> 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 <jh...@pivotal.io> 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 <
>> nchandrappa@pivotal.io> 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*
>
> msecrist@pivotal.io
>
> 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>
>

Re: Question on Querying and PDX Serialization

Posted by Mark Secrist <ms...@pivotal.io>.
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 <jh...@pivotal.io> 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 <nchandrappa@pivotal.io
> > 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*

msecrist@pivotal.io

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>

Re: Question on Querying and PDX Serialization

Posted by Mark Secrist <ms...@pivotal.io>.
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 <jh...@pivotal.io> 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 <nchandrappa@pivotal.io
> > 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*

msecrist@pivotal.io

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>

Re: Question on Querying and PDX Serialization

Posted by Jason Huynh <jh...@pivotal.io>.
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 <nc...@pivotal.io>
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
>

Re: Question on Querying and PDX Serialization

Posted by Jason Huynh <jh...@pivotal.io>.
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 <nc...@pivotal.io>
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
>

Re: Question on Querying and PDX Serialization

Posted by Barry Oglesby <bo...@pivotal.io>.
Nikhil,

If you can't configure PDX on the client (why not, btw?), then you can use
a function to send the data from the client to the server, and then do the
put in that function on the server. That will store the object in PDX
serialized form. Then you can use gfsh to query it back.

Querying from a java client will only work for projections, though, since
the object won't be able to be deserialized on the client.

Here is some code as an example.

Execution execution = FunctionService
.onRegion(this.region)
.withArgs(new Object[] {"AAPL", 100, 114.00})
.withFilter(Collections.singleton(String.valueOf(i)));
ResultCollector collector = execution.execute("PutFunction");

The PutFunction execute method would look like:

public void execute(FunctionContext context) {
// Get region, key and data
RegionFunctionContext rfc = (RegionFunctionContext) context;
Region<String,Trade> region = rfc.getDataSet();
String key = (String) rfc.getFilter().iterator().next();
Object[] arguments = (Object[]) rfc.getArguments();
System.out.println("Executing " + getId() + " with " + key + "->" +
Arrays.toString(arguments));
// Put value
Trade value = new Trade(key, (String)arguments[0], (Integer)arguments[1],
(Float)arguments[2]);
region.put(key, value);
// Return result
context.getResultSender().lastResult(true);
}

gfsh>query --query="SELECT id FROM /data WHERE id='1'"

Result     : true
startCount : 0
endCount   : 20
Rows       : 1

Result
------
1

gfsh>query --query="SELECT * FROM /data WHERE id='1'"

Result     : true
startCount : 0
endCount   : 20
Rows       : 1

shares |      price       | id | cusip
------ | ---------------- | -- | -----
22     | 329.297607421875 | 1  | HMIN


Barry Oglesby
GemFire Advanced Customer Engineering (ACE)
For immediate support please contact Pivotal Support at
http://support.pivotal.io/


On Thu, Dec 3, 2015 at 10:37 AM, Vincent Ford <vf...@pivotal.io> wrote:

> Hi Nikhil,
>
> You need to do one or the other. Without the classes on the server
> classpath then a client will only be able to do gets and puts against the
> server if not using PDX. The serialization of the entry starts at the
> client and default is to use standard Java serialization but this requires
> classes be provided on the server side for deserialization when doing query
> or other operations. Will you have native clients in the future or will
> memory footprint be important when scaling the application then you should
> consider using PDX at the clients.
>
> *Vince Ford*
> GemFire Sustenance Engineering
> Beaverton, OR USA
> 503-533-3726 (office)
> http://www.pivotal.io
> Open Source Project Geode https://geode.incubator.apache.org/
> <https://network.pivotal.io/products/project-geode>
>
> On Thu, Dec 3, 2015 at 10:12 AM, Nikhil Chandrappa <nchandrappa@pivotal.io
> >
> 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
> >
>

Re: Question on Querying and PDX Serialization

Posted by Vincent Ford <vf...@pivotal.io>.
Hi Nikhil,

You need to do one or the other. Without the classes on the server
classpath then a client will only be able to do gets and puts against the
server if not using PDX. The serialization of the entry starts at the
client and default is to use standard Java serialization but this requires
classes be provided on the server side for deserialization when doing query
or other operations. Will you have native clients in the future or will
memory footprint be important when scaling the application then you should
consider using PDX at the clients.

*Vince Ford*
GemFire Sustenance Engineering
Beaverton, OR USA
503-533-3726 (office)
http://www.pivotal.io
Open Source Project Geode https://geode.incubator.apache.org/
<https://network.pivotal.io/products/project-geode>

On Thu, Dec 3, 2015 at 10:12 AM, Nikhil Chandrappa <nc...@pivotal.io>
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
>