问题
I recently had trouble with Hazelcast using ReplicatedMaps in a Dedicated Server / Hazelcast Client environment. I made a Stackoverflow post for it and a Hazelcast Ticket was made for it. Hazelcast ClassNotFound using Near Cache in Client I continued to work in my Environment and stumbled on another Error. I am not sure if it will be covered by a fix for my other problem so I post a new question here: My Environment is: I got a Dedicated Hazelcast 3.9.3 Server with a slightly modified hazelcast.xml. I added
<replicatedmap name="default">
<in-memory-format>BINARY</in-memory-format>
<statistics-enabled>true</statistics-enabled>
</replicatedmap>
I start the Hazelcast Server and watch the console messages.
I also coded a Test Client:
package de.empic.hazelwar;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
import de.empic.hazelwar.model.Cache;
import java.util.Map;
public class Main {
public static final String HAZELCAST_INSTANCE_NAME = "HAZI";
public static final String REPLICATEDMAP_NAME = "REP_MAP";
public static final String MY_KEY = "MyKey";
public static void main(String[] args) {
init();
HazelcastInstance instance = HazelcastClient.getHazelcastClientByName(HAZELCAST_INSTANCE_NAME);
Map<String, Object> repMap = instance.getReplicatedMap(REPLICATEDMAP_NAME);
try {
repMap.remove(MY_KEY);
repMap.put(MY_KEY, new Cache());
} catch (Exception e) {
e.printStackTrace();
}
finally
{
instance.shutdown();
}
}
private static void init() {
ClientConfig cfg = new ClientConfig();
cfg.setInstanceName(HAZELCAST_INSTANCE_NAME);
// for analysis in the hazelcast management console
cfg.getProperties().put("hazelcast.client.statistics.enabled", "true");
cfg.getProperties().put("hazelcast.client.statistics.period.seconds", "60");
cfg.getNetworkConfig().addAddress("127.0.0.1:5701");
if (HazelcastClient.newHazelcastClient(cfg) == null) {
System.err.println(" !!! ERROR in Cache Config !!!");
}
}
}
What I do is to start the client several times directly after the previous run was finished. Every second launch I get an Exception:
INFORMATION: [127.0.0.1]:5701 [dev] [3.9.2] Received auth from Connection[id=16, /127.0.0.1:5701->/127.0.0.1:50403, endpoint=null, alive=true, type=JAVA_CLIENT], successfully authenticated, principal: ClientPrincipal{uuid='68356b07-32dd-4e11-82ed-e3a4611da5a0', ownerUuid='ff081a0d-a52d-47ba-a294-232cee60cd55'}, owner connection: true, client version: 3.9.3
Dez 06, 2018 2:03:23 PM com.hazelcast.replicatedmap.impl.operation.RemoveOperation
SCHWERWIEGEND: [127.0.0.1]:5701 [dev] [3.9.2] java.lang.ClassNotFoundException: de.empic.hazelwar.model.Cache
com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: de.empic.hazelwar.model.Cache
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:224)
at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:185)
at com.hazelcast.spi.impl.NodeEngineImpl.toObject(NodeEngineImpl.java:339)
at com.hazelcast.replicatedmap.impl.record.DataReplicatedRecordStore.unmarshall(DataReplicatedRecordStore.java:38)
at com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore.remove(AbstractReplicatedRecordStore.java:85)
at com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore.remove(AbstractReplicatedRecordStore.java:60)
at com.hazelcast.replicatedmap.impl.operation.RemoveOperation.run(RemoveOperation.java:50)
at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:194)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.run(OperationExecutorImpl.java:406)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.runOrExecute(OperationExecutorImpl.java:433)
at com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvokeLocal(Invocation.java:569)
at com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvoke(Invocation.java:554)
at com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke0(Invocation.java:513)
at com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke(Invocation.java:207)
at com.hazelcast.spi.impl.operationservice.impl.InvocationBuilderImpl.invoke(InvocationBuilderImpl.java:60)
at com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask.processMessage(AbstractPartitionMessageTask.java:67)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:123)
at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:103)
at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:154)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:125)
at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:100)
Caused by: java.lang.ClassNotFoundException: de.empic.hazelwar.model.Cache
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:173)
at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:147)
at com.hazelcast.nio.IOUtil$ClassLoaderAwareObjectInputStream.resolveClass(IOUtil.java:591)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1868)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1751)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2042)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1573)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:431)
at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:219)
... 21 more
To me it looks like an error that Hazelcast tries to deserialize content of a replicated map after I told it to do BINARY in-memory storage.
回答1:
This is fixed by Hazelcast 3.11.1, released yesterday
It was a bug, see https://github.com/hazelcast/hazelcast/issues/14235
来源:https://stackoverflow.com/questions/53652395/hazelcast-classnotfounderror-on-dedicated-member-for-hazelclient-replicated-map