使用kryo序列化时候报错:Kryo Encode error. msg=Class is not registered: com.alicp.jetcache.CacheValueHolder
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
使用kryo作为序列化反序列化工具时报:Class is not registered:
用大神遇到过吗?跪求解决方案!
报错信息:
[2021-04-29 21:21:12,451] ERROR [] c.a.j.AbstractCache[58] - jetcache(RedisCache) PUT error. key=[[1]]
com.alicp.jetcache.support.CacheEncodeException: Kryo Encode error. msg=Class is not registered: com.alicp.jetcache.CacheValueHolder
Note: To register this class use: kryo.register(com.alicp.jetcache.CacheValueHolder.class);
at com.alicp.jetcache.support.KryoValueEncoder.apply(KryoValueEncoder.java:66)
at com.alicp.jetcache.support.KryoValueEncoder.apply(KryoValueEncoder.java:14)
at com.alicp.jetcache.redis.RedisCache.do_PUT(RedisCache.java:163)
maven依赖:
com.alicp.jetcache
jetcache-starter-redis
2.6.0
代码:
@Cached(name="warehouse:code:", cacheType= CacheType.BOTH, expire = 3600, localExpire = 600, localLimit = 1000)
@Override
public WarehouseQO getWarehouseByCode(Long code) {
return warehouseMapper.selectByCode(code);
}
配置信:
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
local:
default:
type: linkedhashmap
keyConvertor: fastjson
remote:
default:
type: redis
keyConvertor: fastjson
valueEncoder: kryo
valueDecoder: kryo
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
host: 192.168.111.109
port: 6379
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the stack-trace locations in KryoValueEncoder.java and RedisCache.java, then inspect the remote cache configuration using the kryo value encoder and decoder. Reproduce the PUT failure with the provided JetCache 2.6.0 setup and determine the expected behavior when CacheValueHolder is not registered; the issue is done when the reported encoding error no longer occurs or the required configuration is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100