Hazelcast Hibernate枚举序列化/反序列化异常

时间:2018-06-23 08:56:56

标签: java hazelcast

我正在尝试将hazelcast与Spring引导项目集成到休眠L2缓存中。

Hazelcast-3.9.4

hazelcast-hibernate4

在集群模式下设置Hibernate L2缓存,并像本机客户端一样进行连接。 设置工作正常(都适用于L2 + Query缓存),我可以在群集中看到数据。

但是现在出现了一个奇怪的异常:-

SEVERE: [10.129.252.157]:5701 [dev] [3.9.4] 
java.io.InvalidObjectException: enum constant DUMMY does not exist in class com.shared.api.bean.pg.PG
com.hazelcast.nio.serialization.HazelcastSerializationException: java.io.InvalidObjectException: enum constant DUMMY does not exist in class com.shared.api.bean.pg.PG
    at com.hazelcast.internal.serialization.impl.SerializationUtil.handleException(SerializationUtil.java:63)
    at com.hazelcast.internal.serialization.impl.AbstractSerializationService.readObject(AbstractSerializationService.java:279)
    at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.readObject(ByteArrayObjectDataInput.java:574)
    at com.hazelcast.hibernate.serialization.Value.readData(Value.java:76)
    at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.readInternal(DataSerializableSerializer.java:158)
    at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:105)
    at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:50)
    at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
    at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:191)
    at com.hazelcast.query.impl.CachedQueryEntry.getValue(CachedQueryEntry.java:75)
    at com.hazelcast.hibernate.distributed.LockEntryProcessor.process(LockEntryProcessor.java:49)
    at com.hazelcast.hibernate.distributed.LockEntryProcessor.process(LockEntryProcessor.java:32)
    at com.hazelcast.map.impl.operation.EntryOperator.process(EntryOperator.java:335)
    at com.hazelcast.map.impl.operation.EntryOperator.operateOnKeyValueInternal(EntryOperator.java:194)
    at com.hazelcast.map.impl.operation.EntryOperator.operateOnKey(EntryOperator.java:179)
    at com.hazelcast.map.impl.operation.EntryOperation.runVanilla(EntryOperation.java:395)
    at com.hazelcast.map.impl.operation.EntryOperation.run(EntryOperation.java:177)
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:194)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.run(OperationExecutorImpl.java:406)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.runOrExecute(OperationExecutorImpl.java:433)
    at com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvokeLocal(Invocation.java:569)
    at com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvoke(Invocation.java:554)
    at com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke0(Invocation.java:513)
    at com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke(Invocation.java:207)
    at com.hazelcast.spi.impl.operationservice.impl.InvocationBuilderImpl.invoke(InvocationBuilderImpl.java:60)
    at com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask.processMessage(AbstractPartitionMessageTask.java:67)
    at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:123)
    at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:103)
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:154)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:125)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:100)
Caused by: java.io.InvalidObjectException: enum constant DUMMY does not exist in class com.shared.api.bean.pg.PG
    at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at java.util.HashMap.readObject(HashMap.java:1404)
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1909)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1808)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:79)
    at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:72)
    at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
    at com.hazelcast.internal.serialization.impl.AbstractSerializationService.readObject(AbstractSerializationService.java:273)
    ... 29 more
Caused by: java.lang.IllegalArgumentException: com.shared.api.bean.pg.PG is not an enum type
    at java.lang.Class.enumConstantDirectory(Class.java:3344)
    at java.lang.Enum.valueOf(Enum.java:232)
    at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1750)
    ... 44 more

我还尝试了Java序列化/反序列化,并能够从枚举中获取值

Hazelcast序列化/反序列化可能是什么问题?

Hz配置:-

<map name="com.entity.*">
        <in-memory-format>BINARY</in-memory-format>
        <backup-count>0</backup-count>
        <async-backup-count>0</async-backup-count>
        <time-to-live-seconds>0</time-to-live-seconds>
        <max-idle-seconds>0</max-idle-seconds>
        <eviction-policy>LRU</eviction-policy>
        <max-size policy="PER_NODE">10000</max-size>
        <eviction-percentage>20</eviction-percentage>
        <merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>
        <read-backup-data>false</read-backup-data>
        <cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
    </map>

0 个答案:

没有答案