Announcement Announcement Module
Collapse
No announcement yet.
PDXSerializer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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).

    Comment


    • #3
      Nightly build triggered: https://build.springsource.org/browse/SGF-NIGHTLY-445

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment


          • #6
            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}" />

            Comment


            • #7
              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.

              Comment


              • #8
                Thanks for your guidance! try it now.

                Comment

                Working...
                X