Hazelcast: DataSerializableFactory[-2] is already registered! com.hazelcast.partition.PartitionDataSerializerHook

Created on 4 Sep 2016  路  5Comments  路  Source: hazelcast/hazelcast

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.(DataSerializableSerializer.java:66)
at com.hazelcast.internal.serialization.impl.SerializationServiceV1.(SerializationServiceV1.java:94)
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.(Node.java:181)
at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:155)
at com.hazelcast.instance.HazelcastInstanceImpl.(HazelcastInstanceImpl.java:126)
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?

hazelcast_with_issue_version_3_7.zip

Most helpful comment

Hi @ohadbehore, can you check you have just a single version of Hazelcast on your classpath?

All 5 comments

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:

  1. an environment with complicated classloading - such as Java EE or OSGIi container - a single Hazecast JAR is loaded by multiple classloaders
  2. having multiple Hazelcast JARs.

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dbrimley picture dbrimley  路  3Comments

kwart picture kwart  路  7Comments

pkgonan picture pkgonan  路  6Comments

varunsufi picture varunsufi  路  5Comments

wolframite picture wolframite  路  6Comments