2012-03-29 89 views
0

我想使用voldemort商店來保存hazelcast中的數據。我實現了mapstore接口。當我嘗試在hazelcast中添加地圖項時,我得到這個異常。Hazelcast類路徑錯誤

29 Mar, 2012 12:19:28 PM com.hazelcast.cluster.ClusterService 
SEVERE: /192.168.100.120:5701 [dev] error processing messages [email protected] 
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的清單文件中添加了一個類路徑條目。

即使這樣,當我嘗試添加一個條目時,它會給出此noclassdef發現的錯誤。 它試圖找到的類肯定是​​在我添加到類路徑的voldemort文件夾中。 我仍然不知道問題是什麼。有人可以提出其他解決方案嗎? 謝謝。

回答

1

您可以嘗試Hazelcast配置並自己設置工廠對象。

// 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");