Results 1 to 8 of 8

Thread: PDXSerializer

  1. #1
    Join Date
    Dec 2011
    Posts
    2

    Default PDXSerializer

    I'm trying to set gemfire cache with pdx-serializer with the new attribute that included in the latest spring-gemfire release , but always fail with error message "Invalid pdx serializer usedclass java.lang.String is not assignable to interface com.gemstone.gemfire.pdx.PdxSerializer" .

    Below is the configuration of gemfire cache and the error information :
    <gfe:cache pdx-read-serialized="true" pdx-serializer="cacheSerializer" />

    <bean id="cacheSerializer" class="com.gemstone.gemfire.pdx.ReflectionBasedAut oSerializer">
    <constructor-arg ref="serializedClasses"></constructor-arg>
    </bean>

    <util:list id="serializedClasses" list-class="java.util.ArrayList" value-type="java.lang.String">
    <value>com.anabatic.zeus.core.intf.Context</value>
    <value>com.anabatic.zeus.core.intf.SessionContex t</value>
    <value>com.anabatic.zeus.core.intf.ObjectMessage </value>
    </util:list>

    Caused by: java.lang.IllegalArgumentException: Invalid pdx serializer usedclass java.lang.String is not assignable to interface com.gemstone.gemfire.pdx.PdxSerializer
    at org.springframework.util.Assert.isAssignable(Asser t.java:368)
    at org.springframework.data.gemfire.CacheFactoryBean$ PdxOptions.run(CacheFactoryBean.java:78)
    at org.springframework.data.gemfire.CacheFactoryBean. applyPdxOptions(CacheFactoryBean.java:180)
    at org.springframework.data.gemfire.CacheFactoryBean. afterPropertiesSet(CacheFactoryBean.java:143)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
    ... 16 more


    Any idea how to get spring-gemfire work with pdx-serializer? I couldn't found any guideline from the spring-gemfire user manual related this new attribute

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Looks like you've run into a bug. Your configuration is fine - is just that the namespace handler consider the bean name rather then its reference as its target. A fix has been pushed into master - I've also triggered the nightly build so you can try it in 10 minutes or so.

    As an alternative you can use the plain bean definition rather then the namespace as a workaround - from the top of my head:

    Code:
    <bean id="gemfire-cache" class="org.springframework.gemfire.CacheFactoryBean" p:pdx-read-serialized="true" 
                  p:pdx-serializer-ref="cacheSerializer"/>
    (note this uses the p: namespace - see the Spring docs or google for more info if you're not familiar with it).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Dec 2011
    Posts
    2

    Default

    Already try the workaround and the initialization process is fine, but still couldn't get the pdx serializer working as expected, cache writer doesn't recognize the pdx serializer.

    Currently I'm creating custom serializer that work perfectly fine, just need to figure out how to make the serializer recognize new class without manually add it into the supported class list while the serializer actually able to serialize object dynamically similar to the reflection based pdx-serializer

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I don't know what to tell you - it might be a GemFire specific topic. It's worth checking (with the docs or GemFire forum) whether the pdx will be used only at the cache level or through-out the infrastructure (like the cache/loader/writer) as well.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6
    Join Date
    Feb 2012
    Posts
    2

    Default

    until the bugfix is in the RELEASE (and not SNAPSHOT), i work around it using SpEL "eval" hack:

    Code:
    <gfe:cache pdx-read-serialized="true" pdx-serializer="#{cacheSerializer}" />

  7. #7
    Join Date
    Sep 2012
    Posts
    1

    Default

    The PdxSerializer interface allows domain classes to be serialized and deserialized as PDXs without modification of the domain class. It only requires that the domain class have a public zero-arg constructor and that it provides read and write access to the PDX serialized fields.

    Gem Fire allows a single PdxSerializer to be configured on a cache using setPdxSerializer or client setPdxSerializer. It can also be configured in cache.xml using the pdx-serializer element. The same PdxSerializer should be configured on each member of a distributed system that can serialize or deserialize PDX data.

  8. #8
    Join Date
    Mar 2013
    Posts
    1

    Default

    Thanks for your guidance! try it now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •