I tried to run the following code:
HazelcastInstance hz = null;
try {
hz = Hazelcast.newHazelcastInstance();
Address localMemberInstance = hz.getCluster().getLocalMember().getAddress();
Set<Member> allMembers = hz.getCluster().getMembers();
for (Member currMember : allMembers) {
if (localMemberInstance.getHost().equals(currMember.getAddress().getHost()) && localMemberInstance.getPort() == currMember.getAddress().getPort() ) {
CacheLogger.log(Level.ERROR, "*Local Hazelcast Server IP=" + localMemberInstance.getHost() + " , port=" + localMemberInstance.getPort() + ", ID=" + localMemberInstance.getId());
} else {
CacheLogger.log(Level.ERROR, "Remote Hazelcast Server IP=" + currMember.getAddress().getHost() + " , port=" + currMember.getAddress().getPort() + ", ID=" + currMember.getAddress().getId());
}
}
} catch (Exception e) {
e.printStackTrace();
}
And I got the following exception:
INFO: Loading 'hazelcast.xml' from classpath.
java.lang.IllegalArgumentException: DataSerializableFactory[-2] is already registered! com.hazelcast.partition.PartitionDataSerializerHook$1@1a18644 -> com.hazelcast.internal.partition.impl.PartitionDataSerializerHook$1@5acf93bb
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.register(DataSerializableSerializer.java:87)
at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.
at com.hazelcast.internal.serialization.impl.SerializationServiceV1.
at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.createSerializationService(DefaultSerializationServiceBuilder.java:264)
at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.build(DefaultSerializationServiceBuilder.java:218)
at com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder.build(DefaultSerializationServiceBuilder.java:46)
at com.hazelcast.instance.DefaultNodeExtension.createSerializationService(DefaultNodeExtension.java:126)
at com.hazelcast.instance.Node.
at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:155)
at com.hazelcast.instance.HazelcastInstanceImpl.
at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:218)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:176)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:126)
at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:87)
at com.unisfair.hazelcastinstance.HazelcastInstanceServerMain.main(HazelcastInstanceServerMain.java:26)
I have to mention that the exception occurred when I changed the hazelcast jar version from hazelcast 3.6 to hazelcast 3.7.
I attached the hazelcast.xml configuration file.
Does anyone have an idea what is the issue here?
Hi @ohadbehore, can you check you have just a single version of Hazelcast on your classpath?
I'm running a simple application from eclipse. And it has only hazelcast-all-3.7.jar
There are no other versions in the classpath.
That's odd. I've seen this error a few times. It was always caused by one of these:
I created a new project and used your configuration, but I could not reproduce it. I was using IntelliJ and not Eclipse, but should not play any role here. Could you prepare an example project manifesting the bug?
The problem was that in the pom.xml (maven) relating to the project there was a reference for hazelcast version 3.6 .
Sorry I did not notice that before. You were right.
that's great to know, thanks for heads-up!
Most helpful comment
Hi @ohadbehore, can you check you have just a single version of Hazelcast on your classpath?