我最近在专用服务器/ Hazelcast Client环境中使用ReplicatedMaps困扰Hazelcast。我为此制作了一个Stackoverflow帖子,并为此制作了Hazelcast票。 Hazelcast ClassNotFound using Near Cache in Client 我继续在我的环境中工作,偶然发现了另一个错误。我不确定其他问题的修复程序是否涵盖该问题,因此我在此处发布了一个新问题: 我的环境是: 我得到了带有经过稍微修改的hazelcast.xml的专用Hazelcast 3.9.3服务器。我添加了
<replicatedmap name="default">
<in-memory-format>BINARY</in-memory-format>
<statistics-enabled>true</statistics-enabled>
</replicatedmap>
我启动Hazelcast服务器并观看控制台消息。
我还编码了一个测试客户端:
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 !!!");
}
}
}
我要做的是在上一次运行完成后立即多次启动客户端。 每次启动我都会收到一个异常:
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
在我看来,Hazelcast在我告诉它执行BINARY内存存储后试图反序列化已复制映射的内容,似乎是一个错误。
答案 0 :(得分:1)
此问题已由昨天发布的Hazelcast 3.11.1修复
这是一个错误,请参见https://github.com/hazelcast/hazelcast/issues/14235