Hazelcast无法对枚举类进行反序列化

时间:2015-08-11 11:32:32

标签: hazelcast

我在Hazelcast反序列化方面遇到了一些问题。我不知道为什么会发生这种情况。

当我使用Maven构建项目时,我可以看到下一个错误代码:

GRAVE: Failed to execute callback:     com.hazelcast.client.proxy.ClientMapProxy$1@382710c7! Request:     com.hazelcast.map.impl.client.MapGetRequest@cbe959e, response: HeapData{type=-    25,
hashCode=1128451374, partitionHash=1128451374, dataSize=89, heapCost=117}
com.hazelcast.nio.serialization.HazelcastSerializationException: Failed to deserialize enum: com.grupo.exception.ExceptionCauseEnum
    at     com.hazelcast.nio.serialization.DefaultSerializers$EnumSerializer.read(DefaultSerializers.java:243)
    at com.hazelcast.nio.serialization.DefaultSerializers$EnumSerializer.read(DefaultSerializers.java:225)
    at com.hazelcast.nio.serialization.StreamSerializerAdapter.toObject(StreamSerializerAdapter.java:65)
    at com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:260)
    at com.hazelcast.client.spi.impl.ClientCallFuture$1.run(ClientCallFuture.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
    at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
Caused by: java.lang.ClassNotFoundException: com.grupo.exception.ExceptionCauseEnum
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
    at com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:124)
    at com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:113)
    at com.hazelcast.nio.serialization.DefaultSerializers$EnumSerializer.read(DefaultSerializers.java:241)
    ... 9 more

ExceptionCauseEnum在我的类路径中。

我的 Hazelcast实例配置(以防它有用):

<hz:hazelcast id="instance">
    <hz:config>
        <hz:group name="${name}"
            password="${pass}" />

        <hz:network port="23456"
            port-auto-increment="true">
            <hz:join>
                <hz:multicast
                    enabled="false"
                    multicast-group="${multicast-group}"
                    multicast-port="${multicast-port}" />
                <hz:tcp-ip enabled="true">
                    <hz:interface>127.0.0.1</hz:interface>
                </hz:tcp-ip>
            </hz:join>
            <hz:interfaces enabled="false">
                <hz:interface></hz:interface>
            </hz:interfaces>
        </hz:network>

        <hz:map name="myMap" max-size="5000" max-idle-seconds="3600" 
            time-to-live-seconds="7200" eviction-percentage="25"
            eviction-policy="LRU" />
    </hz:config>
</hz:hazelcast>

虽然Maven把这个错误抛给了我,但是它构建正确。

知道发生了什么,我做错了什么?

提前致谢。

1 个答案:

答案 0 :(得分:1)

我有一个类似的问题:在我的情况下,我的枚举有一个构造函数,所以我的解决方案是创建一个无参数的构造函数。