gpt4 book ai didi

java - "Failed to deserialize object"在点燃缓存中插入对象时出错

转载 作者:搜寻专家 更新时间:2023-11-01 03:32:31 26 4
gpt4 key购买 nike

在字符串键上插入 pojoClass 对象时发生以下错误。我在 Ignite 配置中包含了所有事件类型。

我试过 setStoreKeepBinary(true) 也试过 igniteConfiguration.setPeerClassLoadingEnabled(true) 但错误没有解决。

我使用的是 Apache Ignite 2.1 版。

错误日志:

[2017-09-06 16:22:08,043][ERROR][tcp-client-disco-msg-worker-#4%null%]     [TcpDiscoverySpi] Failed to unmarshal discovery data for component: 0
class org.apache.ignite.IgniteCheckedException: Failed to deserialize object with given class loader: sun.misc.Launcher$AppClassLoader@75b84c92
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:129)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:143)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
at org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket.unmarshalData(DiscoveryDataPacket.java:274)
at org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket.unmarshalGridData(DiscoveryDataPacket.java:131)
at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.onExchange(TcpDiscoverySpi.java:1820)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.processNodeAddFinishedMessage(ClientImpl.java:1985)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.processDiscoveryMessage(ClientImpl.java:1864)
at org.apache.ignite.spi.discovery.tcp.ClientImpl$MessageWorker.body(ClientImpl.java:1758)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.io.InvalidObjectException: Failed to find cache for name: CACHE
at org.apache.ignite.internal.processors.cache.GridCacheContext.readResolve(GridCacheContext.java:2139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1148)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2036)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.readExternal(IgniteCacheProxy.java:2782)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2076)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2025)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2245)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2125)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2245)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2125)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2027)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.apache.ignite.internal.GridEventConsumeHandler.readExternal(GridEventConsumeHandler.java:452)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2076)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2025)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryDataItem.readExternal(GridContinuousProcessor.java:1812)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2076)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2025)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.apache.ignite.internal.util.IgniteUtils.readList(IgniteUtils.java:5299)
at org.apache.ignite.internal.util.IgniteUtils.readCollection(IgniteUtils.java:1739)
at org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryData.readExternal(GridContinuousProcessor.java:1727)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:2076)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2025)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:121)
... 10 more
Caused by: java.lang.IllegalStateException: Failed to find cache for name: CACHE
at org.apache.ignite.internal.processors.cache.GridCacheContext.readResolve(GridCacheContext.java:2134)
... 49 more

缓存配置:

  CacheConfiguration<String, pojoClass> cacheConfig = new CacheConfiguration<>();
cacheConfig.setName("CACHE");
cacheConfig.setBackups(2);
cacheConfig.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheConfig.setIndexedTypes(String.class, pojoClass.class);
// cacheConfig.setStoreKeepBinary(true);
IgniteCache<String, pojoClass> Cache = ignite.getOrCreateCache(cacheConfig);

插入 pojoClass 对象时的代码:

PojoClass pojoObj = new PojoClass(key, name,jsonObject);
Cache.put(key, pojoObj);

这里的 PojoClass 是:

public class PojoClass{
@QuerySqlField
String key;
@QuerySqlField
String name;
@QuerySqlField
JSONObject jsonObject;
public PojoClass(String key, String name,JSONObject jsonObject) {
this.key = key;
this.name = name;
this.jsonObject = jsonObject;
}
}

最佳答案

在创建缓存和执行事件功能时使用相同的 Ignite 实例后,错误得到解决我使用的是发生上述问题的不同 Ignite 实例。

关于java - "Failed to deserialize object"在点燃缓存中插入对象时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46073886/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com