随笔 - 832  文章 - 2  评论 - 31  阅读 - 167万

redis 反序列化deserialize异常问题解决

异常信息:

ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is org.springframework.core.NestedIOException: Failed to deserialize object type; nested exception is java.lang.ClassNotFoundException: com.xxx.tpam.dao.model.Dict] with root cause
java.lang.ClassNotFoundException: com.xxx.tpam.dao.model.Dict

分析:这个错误提示找不到类,反序列化的时候报错,而对象系列化时是跟对象所处的包路径相关的。

 我本地测试,几个系统用的同一个redis,对象在一个系统中序列化存入redis,包路径com.xxx.tpam.dao.model.Dict;主要原因是因为key也是相同,在运行另一个系统时,发现这个key已经存在了,取出时,因当前这个系统包路径为com.xxx.book.dao.model.Dict,由于两个对象的类所处的包路径不一致,反序列化失败,因而报找不到类错误。

解决方法:

直接删除redis中对应的值即可

我是使用的本地库,就直接在redis-cli 执行了flushall(删除所有数据库中的所有key ) 命令

参考:https://cloud.tencent.com/developer/article/1399860

 

posted on   小破孩楼主  阅读(4419)  评论(1编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2019-02-18 oracle的decode函数
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示