Hazelcast: MergeOperation throw ClassNotFoundException

Created on 6 Jan 2014  路  7Comments  路  Source: hazelcast/hazelcast

I just want to use hazelcast like memcached, so the hazelcast server node do not contain any other jar.

First, it works fine. Several hours later, throw ClassNotFoundException.

com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.test.xxx
        at com.hazelcast.nio.serialization.DefaultSerializers$ObjectSerializer.read(DefaultSerializers.java:190)
        at com.hazelcast.nio.serialization.StreamSerializerAdapter.read(StreamSerializerAdapter.java:59)
        at com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:218)
        at com.hazelcast.spi.impl.NodeEngineImpl.toObject(NodeEngineImpl.java:156)
        at com.hazelcast.map.MapService.toObject(MapService.java:651)
        at com.hazelcast.map.operation.MergeOperation.run(MergeOperation.java:48)
        at com.hazelcast.spi.impl.OperationServiceImpl.doRunOperation(OperationServiceImpl.java:274)
        at com.hazelcast.spi.impl.OperationServiceImpl.access$800(OperationServiceImpl.java:52)
        at com.hazelcast.spi.impl.OperationServiceImpl$LocalOperationProcessor.run(OperationServiceImpl.java:710)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

com.hazelcast.map.operation.MergeOperation

public void run() {
    SimpleEntryView entryView = (SimpleEntryView) mergingEntry;
    entryView.setKey(mapService.toObject(mergingEntry.getKey()));
    entryView.setValue(mapService.toObject(mergingEntry.getValue()));
    merged = recordStore.merge(dataKey, mergingEntry, mergePolicy);
    if (merged) {
        Record record = recordStore.getRecord(dataKey);
        if (record != null)
            dataValue = mapService.toData(record.getValue());
    }
}

I think that mapService.toObject is not necessary.

Defect

All 7 comments

Which version of Hazelcast are you using? And which class is being deserialized: com.test.xxx?

Are you sure that each node has the same configuration? And can you post that class that is deserialized and its serialization configuration.

hazelcast version is 3.1.3.

Each node has the same configuration.

com.test.xxx is just a smiple class.

I just use hazelcast as memcached. I use hazelcast-client connect to the hazelcast server cluster(three node).
In the client side, put one com.test.xxx object into the map.
In the hazelcast server cluster side, do not contain the Class File of com.test.xxx.

Beacuse in the hazelcast server cluster side the default in-memory-format is binary, so it works ok.

But when MergeOperation happen, one node receive MergeOperation request, it will call mapService.toData(record.getValue()), then throw ClassNotFoundException.

I guess this happens to the fact that MergePolicies need both values in deserialized form. So it is deserialized to push it over to the merge policy.

By default Merge Policy run with deserialized objects. Therefore, you need to provide the class in the all nodes.

Can you check if all your servers have the necessary class in the classpath?

I am closing the issue. Please re-open it if you reproduce it.

I am seeing this same issue. We have two webapps running under the same tomcat, both using hazelcast but configured with different group names. My webapp throws an exception when the other one puts a class (which is not in my classpath) in his cluster.

com.hazelcast.nio.serialization.HazelcastSerializationException: Problem while reading DataSerializable, namespace: 0, id: 0, class: com.snapone.sync.authorization.SubscriptionCacheModel, exception: com.snapone.sync.authorization.SubscriptionCacheModel
at com.hazelcast.nio.serialization.DataSerializer.read(DataSerializer.java:114) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.nio.serialization.DataSerializer.read(DataSerializer.java:36) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.nio.serialization.StreamSerializerAdapter.read(StreamSerializerAdapter.java:59) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:218) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.spi.impl.NodeEngineImpl.toObject(NodeEngineImpl.java:156) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.map.MapService.toObject(MapService.java:637) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.map.operation.MergeOperation.run(MergeOperation.java:48) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.spi.impl.OperationServiceImpl.doRunOperation(OperationServiceImpl.java:274) [hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.spi.impl.OperationServiceImpl.access$800(OperationServiceImpl.java:52) [hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.spi.impl.OperationServiceImpl$RemoteOperationProcessor.run(OperationServiceImpl.java:744) [hazelcast-3.1.1.jar:3.1.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
at com.hazelcast.spi.impl.OperationServiceImpl$OperationThread.run(OperationServiceImpl.java:791) [hazelcast-3.1.1.jar:3.1.1]
Caused by: java.lang.ClassNotFoundException: com.snapone.sync.authorization.SubscriptionCacheModel
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701) ~[tomcat-catalina-7.0.26.jar:7.0.26]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546) ~[tomcat-catalina-7.0.26.jar:7.0.26]
at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:83) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.nio.ClassLoaderUtil.newInstance(ClassLoaderUtil.java:50) ~[hazelcast-3.1.1.jar:3.1.1]
at com.hazelcast.nio.serialization.DataSerializer.read(DataSerializer.java:103) ~[hazelcast-3.1.1.jar:3.1.1]
... 13 common frames omitted

I have the same problem with Hazelcast version 3.7.2.

Was this page helpful?
0 / 5 - 0 ratings