spring - com.hazelcast.core.DuplicateInstanceNameException HazelcastInstance with name already exists -
i getting error while integrating spring hazelcast. please see hazelcast configuration in spring-servelt.xml. error occurs when autowired hazelcast. please help.
hazel case configuration in spring.xml
<hz:hazelcast id="srmscacheinstance"> <hz:config> <hz:instance-name>trunk</hz:instance-name> <hz:group name="trunk" password="trunk" /> <hz:management-center enabled="false" url="http://127.0.0.1:8080/mancenter-3.2.1" /> <hz:properties> <hz:property name="hazelcast.logging.type">log4j</hz:property> </hz:properties> <hz:network port="5701" port-auto-increment="true"> <hz:join> <hz:multicast enabled="true" multicast-group="224.2.2.3" multicast-port="54333" /> </hz:join> </hz:network> <hz:map name="srmscache" read-backup-data="false"> <hz:near-cache in-memory-format="object" cache-local-entries="true" /> </hz:map> <hz:map name="cache.graph.tx" eviction-policy="lru" eviction-percentage="30" read-backup-data="true" /> <hz:map name="cache.graph.no.tx" eviction-policy="lru" eviction-percentage="30" read-backup-data="true" /> </hz:config> </hz:hazelcast>
autowired in service class
@defaultcustomservice("defaultcachingservice") public class defaultcachingservice { private hazelcastinstance hazelcast; @autowired public void sethazelcast(hazelcastinstance hazelcast) { // hazelcast.shutdownall(); this.hazelcast = hazelcast; } protected hazelcastinstance hazelcast() { return hazelcast; } public object getcachedvalue(string mapkey, string cachekey) throws exception { return hazelcast().getmap(mapkey).get(cachekey); } public object deletecachedvalue(string mapkey, string cachekey) throws exception { return hazelcast().getmap(mapkey).remove(cachekey); } }
following error coming when start server
bean instantiation via factory method failed; nested exception org.springframework.beans.beaninstantiationexception: failed instantiate [com.hazelcast.core.hazelcastinstance]: factory method 'newhazelcastinstance' threw exception; nested exception com.hazelcast.core.duplicateinstancenameexception: hazelcastinstance name 'trunk' exists! @
regards, mmanish
Comments
Post a Comment