5 Replies Latest reply on Feb 21, 2012 2:52 AM by galder.zamarreno

    Error while adding user defined advancedExternalizers programatically in Infinispan 5.1.1

    ursudheesh

      Hi ,

       

      I did follow the updated user-guide for plugging  user defined externalizers.

      https://docs.jboss.org/author/display/ISPN/Plugging+Infinispan+With+User+Defined+Externalizers

       

       

      I have followed the example Person.PersonExteranlizer implementing the AdvacnedExternalizer. I have been able to register the externalizer using the configuration as mentioned.

       

      However when i register them programtically like this:

       

      public class MyCacheClient {

       

                public static void main(String args[]) {

       

                          EmbeddedCacheManager embCacheMgr = null;

                          Person personBeanObj = new Person("Sudheesh",29);

       

       

                                    try {

                                              embCacheMgr = new DefaultCacheManager("InfinispanCfgForNode1.xml");

                                              GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder();

                                              builder.serialization().addAdvancedExternalizer(new Person.PersonExternalizer());

       

                                              Cache personCache = embCacheMgr.getCache("InfinispanClientTest");

       

                                              personCache.put("person1",personBeanObj);

                                              Object cachedObj =  personCache.get("person1");

       

                                              if(cachedObj.equals(personBeanObj)){

                                                        logger.info("Success----------The objects are equal");

                                              }

       

       

                                              personCache.stop();

                                              embCacheMgr.stop();

                                    } catch (IOException e) {

                                              // TODO Auto-generated catch block

                                              e.printStackTrace();

                                    }

       

                }

       

       

       

       

      }

       

      and execute i get the following error:

       

       

      Exception in thread "main" org.infinispan.marshall.NotSerializableException: com.hp.usage.datastruct.beans.mycompany.Person

      Caused by: an exception which occurred:

                in object com.hp.usage.datastruct.beans.mycompany.Person@ad157f

                          -> toString = com.hp.usage.datastruct.beans.mycompany.Person@ad157f

                in object org.infinispan.container.entries.ImmortalCacheEntry@1b173583

                          -> toString = ImmortalCacheEntry{key=person1, value=ImmortalCacheValue {value=com.hp.usage.datastruct.beans.mycompany.Person@ad157f}}

                in object org.infinispan.loaders.bucket.Bucket@717d91

                          -> toString = Bucket{entries={person1=ImmortalCacheEntry{key=person1, value=ImmortalCacheValue {value=com.hp.usage.datastruct.beans.mycompany.Person@ad157f}}}, bucketId='-678441984'}

       

       

      I am using a distributed cache configuration for testing.

       

      Pls help me on this error.

       

      regards

      Sudheesh