2 Replies Latest reply on Jul 22, 2011 3:58 AM by galder.zamarreno

    Is It Possible To Externalize ConcurrentHashmap Object With Infinispan?

    evpgud

      Hello All,

       

      I am struggling with this issue.

       

      I have a domain class<ABC> which has a ConcurrentHashMap<Long,Long> member

       

      and I could not externalize it. Some how the read operation always throws null pointer exception

       

      Caused by: java.lang.NullPointerException

              at org.infinispan.marshall.MarshallUtil.unmarshallMap(MarshallUtil.java:66)

              at org.infinispan.marshall.exts.MapExternalizer.readObject(MapExternalizer.java:81)

       

       

       

      My externalizer class is

       

       

      @SerializeWith(ABCMarshalling.ABCMarshallingExternalizer.class)

      public class ABCMarshalling {

       

       

          @Override

          public String toString() {

                return getMap().toString();

          }

       

       

          ConcurrentHashMap<Long, Long> map = new ConcurrentHashMap<Long, Long>();

       

       

          public ConcurrentHashMap<Long, Long> getMap() {

                return map;

          }

       

       

          public void setMap(ConcurrentHashMap<Long, Long> map) {

                this.map = map;

          }

       

       

          public ABCMarshalling() {

       

       

          }

       

       

          public static class ABCMarshallingExternalizer implements

                    AdvancedExternalizer<ABCMarshalling> {

       

       

                @Override

                public void writeObject(ObjectOutput output,

                          ABCMarshalling object) throws IOException {

                    MapExternalizer ma = new MapExternalizer();

                    ma.writeObject(output, object.getMap());

                }

       

       

                @Override

                public ABCMarshalling readObject(ObjectInput input)

                          throws IOException, ClassNotFoundException {

                    ABCMarshalling hi = new ABCMarshalling();

                    MapExternalizer ma = new MapExternalizer();

                    hi.setMap((ConcurrentHashMap<Long, Long>) ma

                              .readObject(input));

                    return hi;

       

       

                }

       

       

                @Override

                public Set<Class<? extends ABCMarshalling>> getTypeClasses() {

                    return Util

                              .<Class<? extends ABCMarshalling>> asSet(ABCMarshalling.class);

                }

       

       

                @Override

                public Integer getId() {

                    return  3 ;

                }

       

       

          }

         

      }

       

      Is it possible to externalize ConcurrentHashMap object in Infinispan

       

       

      Best Regards