gpt4 book ai didi

java - Hazelcast 类路径错误

转载 作者:行者123 更新时间:2023-12-01 15:28:09 25 4
gpt4 key购买 nike

我正在尝试使用 voldemort 存储将数据保存在 hazelcast 中。我实现了 map 存储接口(interface)。当我尝试在 hazelcast 中添加 map 条目时,出现此异常。

29 Mar, 2012 12:19:28 PM com.hazelcast.cluster.ClusterService
SEVERE: /192.168.100.120:5701 [dev] error processing messages processable=com.hazelcast.cluster.ClusterService$1@561777b1
java.lang.NoClassDefFoundError: voldemort/client/StoreClientFactory
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)
at java.lang.Class.getConstructor0(Class.java:2716)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at com.hazelcast.impl.CMap.<init>(CMap.java:203)
at com.hazelcast.impl.ConcurrentMapManager.getOrCreateMap(ConcurrentMapManager.java:2160)
at com.hazelcast.impl.FactoryImpl.createProxy(FactoryImpl.java:735)
at com.hazelcast.impl.FactoryImpl$7.process(FactoryImpl.java:809)
at com.hazelcast.cluster.ClusterService$1.process(ClusterService.java:126)
at com.hazelcast.cluster.ClusterService.processProcessable(ClusterService.java:190)
at com.hazelcast.cluster.ClusterService.dequeueProcessables(ClusterService.java:256)
at com.hazelcast.cluster.ClusterService.run(ClusterService.java:201)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: voldemort.client.StoreClientFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 14 more

这是我编辑的 hazelcast run.sh 脚本,以便将 voldemort jar 包含在类路径中。

#!/bin/sh
java -Djava.net.preferIPv4Stack=true -cp ./:/home/gerrard/workspace/hazelcast/bin/:/home/gerrard/work/voldemort- 0.90.1/lib/:/home/gerrard/work/voldemort-0.90.1/dist/:/home/gerrard/work/voldemort- 0.90.1/bin/:../lib/hazelcast-2.0.1.jar com.hazelcast.examples.TestApp

我还在 hazelcast.xml 文件中添加了我的实现类。

我还在 hazelcast-2.0.1.jar 的 list 文件中添加了一个类路径条目。

即使如此,当我尝试添加条目时,它也会出现 noclassdef find 错误。它试图找到的类肯定位于我添加到类路径中的 voldemort 文件夹中。我仍然不知道问题是什么。有人可以建议任何替代解决方案吗?谢谢。

最佳答案

您可以尝试 Hazelcast Config 并自行设置 Factory 对象。

// Build the config from xml file you have in the classpath
Config config = new XmlConfigBuilder().build();
MapStoreConfig msc = new MapStoreConfig..
msc.setFactoryImplementation(new StoreClientFactory());
MapConfig mapConfig = new MapConfig..
mapConfig.setMapStoreConfig(msc);
config.addMapConfig(mapconfig);

// init Hazelcast with this configuration
// make sure you call init fore any other Hazelcast operation!!
Hazelcast.init(config);

// then access to your map
Map map = Hazelcast.getMap("mymap");

关于java - Hazelcast 类路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9920534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com