首页 > 数据库 >org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested excepti

org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested excepti

时间:2022-11-24 13:31:58浏览次数:45  
标签:core java deserialize SerializationException redis springframework apache org Ap


摘要

Spring Boot项目连接Redis报错

报错信息

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 java.io.InvalidClassException: com.thunisoft.wsla.model.Dm; local class incompatible: stream classdesc serialVersionUID = 7418997265931921799, local class serialVersionUID = 4605616598199579320
at com.thunisoft.wsla.redis.RedisObjectSerializer.deserialize(RedisObjectSerializer.java:27)
at org.springframework.data.redis.serializer.SerializationUtils.deserializeValues(SerializationUtils.java:54)
at org.springframework.data.redis.serializer.SerializationUtils.deserialize(SerializationUtils.java:68)
at org.springframework.data.redis.core.AbstractOperations.deserializeValues(AbstractOperations.java:268)
at org.springframework.data.redis.core.DefaultListOperations.lambda$range$6(DefaultListOperations.java:171)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
at org.springframework.data.redis.core.DefaultListOperations.range(DefaultListOperations.java:171)
at com.thunisoft.wsla.redis.RedisCache.getList(RedisCache.java:147)
at com.thunisoft.wsla.service.DmService.getDmList(DmService.java:52)
at com.thunisoft.wsla.controller.DmController.getDmList(DmController.java:69)
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 org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:158)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:126)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:84)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: com.thunisoft.wsla.model.Dm; local class incompatible: stream classdesc serialVersionUID = 7418997265931921799, local class serialVersionUID = 4605616598199579320
at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:78)
at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:36)
at com.thunisoft.wsla.redis.RedisObjectSerializer.deserialize(RedisObjectSerializer.java:25)
... 79 common frames omitted
Caused by: java.io.InvalidClassException: com.thunisoft.wsla.model.Dm; local class incompatible: stream classdesc serialVersionUID = 7418997265931921799, local class serialVersionUID = 4605616598199579320
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:616)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1843)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1713)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2000)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1535)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:422)
at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:72)
at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:73)
... 81 common frames omitted

解决方法

最后发现是因为2个应用共用了同一个Redis的同一个database导致的反序列化失败,把其中一个应用的Redis的database改成和另一个不一样的就可以正常使用了。


标签:core,java,deserialize,SerializationException,redis,springframework,apache,org,Ap
From: https://blog.51cto.com/u_4679008/5883594

相关文章

  • com.alibaba.fastjson.JSONException: can not get javaBeanDeserializer. java.util.
    摘要:SpringBoot接收前端传过来的日期字段解析报错报错信息com.alibaba.fastjson.JSONException:cannotgetjavaBeanDeserializer.java.util.Dateatcom.alibaba.fast......
  • redis-cli命令行采集信息时遇到的一个小疑问
    给客户巡检的时候,之前想当然看-c可以通过命令行运行一些命令,方便巡检采集信息,比如:[root@xweisrc]$./redis-cli-h127.0.0.1-aabc123-p7379-c"info"|head-n5......
  • Redis管理平台Cachecloud使用LDAP进行认证登录
    cachecloud版本:https://github.com/sohutv/cachecloud/archive/refs/tags/2.2.tar.gz 公司使用ldap的ssl认证,java本人一点都不懂,耗费几天时间没有搞定,只能曲线救国,使用s......
  • redis的持久化
    redis是一种基于内存的非关系型数据库,内存虽然快但是数据也更易丢失,所以redis提供了两种持久化方式,分别是RDB和AOF,今天就介绍下这两种持久化方式以及原理一、RDB1、介绍......
  • Redis知识
     Redis是什么Redis是一种基于内存的数据库,对数据的读写操作都是在内存中完成,因此读写速度非常快,常用于缓存,消息队列、分布式锁等场景。 Redis&Memcached......
  • redis 缓存设计之穿透击穿雪崩
    缓存穿透缓存穿透是指查询一个根本不存在的数据,缓存层和存储层都不会命中,通常处于容错的考虑,如果从存储层查不到数据则不写入缓冲层缓存穿透将导致不存在的数据每次请求......
  • redis通过lua脚本------实现原子性操作(PHP代码实现)
    背景一直都知道redis里可以执行lua脚本,但是以前一直搞不懂redis为啥要这么搞,今天看了人家一篇博文,说秒杀场景出现商品超卖,解决方案是利用lua脚本来保证操作的原子性自己......
  • Redis后端面试题
    目录简要说一下什么是Redis?为什么要⽤Redis(缓存)?为什么要⽤Redis⽽不⽤map/guava做缓存?Redis与Memcached的区别Redis的应⽤场景redis为什么那么快redis有哪些数......
  • redis启动客户端
    启动Redis启动方式:①前台启动redis-server②后台启动redis-server&最好使用后台启动,不占用命令终端.③根据配置文件启动启动命令配置文件&启动redis服务时,指......
  • 【Azure Redis 缓存】在Azure Redis中,如何限制只允许Azure App Service访问?
    问题描述在AzureRedis服务中,如何实现只允许AzureAppService访问呢? 问题解答AzureRedis开启防火墙的功能,并在防火墙中添加上AppService的出口IP地址即可。两步......