Config config = new Config(); HazelcastInstance h = Hazelcast.newHazelcastInstance(config); ConcurrentMap<String, String> map = h.getMap("my-distributed-map"); map.put("key", "value"); map.get("key"); //Concurrent Map methods map.putIfAbsent("somekey", "somevalue");
Running the debugger in eclipse, an exception is thrown on the putIfAbsent line:
Caused by: java.io.NotSerializableException: com.hazelcast.instance.HazelcastInstanceProxy at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330) at com.hazelcast.nio.serialization.DefaultSerializers$ObjectSerializer.write(DefaultSerializers.java:204) at com.hazelcast.nio.serialization.StreamSerializerAdapter.write(StreamSerializerAdapter.java:48) at com.hazelcast.nio.serialization.SerializationServiceImpl.toData(SerializationServiceImpl.java:176) ... 94 more
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/a2b08965-438d-4ea5-a0a8-f93915d598d5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
What's your runtime environment? Anything with classloaders like Servlet Container, OSGi or JEE? I know that problem if Hazelcast classloader wasn't able to find / register the base seriliazers.
Chris
map.putIfAbsent("somekey", myClass);
myClass looks like:
class MyClass implements Serializable {
private static final long serialVersionUID = 1L;
String user;
Long timestamp;
public MyClass(String currentUser, long l) {
this.user = currentUser;
this.timestamp = l;
}
}
I changed it to map.putIfAbsent("somekey", "somevalue"); using a String for the map value instead of myClass and the problem went away. I'm puzzled because I've seen hazelcast examples using custom objects in the map, so not sure why it's a problem for me. It would be handy if I were able to use an object, but could work around it. I'm just happy I got it working, pretty impressed with hazelcast thus far. Thanks for the replies.
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/b202326b-585a-486f-8afb-36536f778199%40googlegroups.com.